How to increase default datatable_length to all and print button in a same page?

How to increase default datatable_length to all and print button in a same page?

brittalpanabrittalpana Posts: 8Questions: 2Answers: 0

How to increase default datatable_length to all and print button in a same page?

This question has an accepted answers - jump to answer

Answers

  • brittalpanabrittalpana Posts: 8Questions: 2Answers: 0
    edited January 2015
    $(document).ready(function() {
        $('#example').DataTable( {
            "dom": 'T<"clear">lfrtip',
            "tableTools": {
                "aButtons": [
                    "print",
                    {
                        "sExtends":    "Print",
                        
                    }
                ]
            }
        } );
    } );
    
    $('#example').DataTable({
                        "bJQueryUI": true,
                        "bDestroy": true,
                        "aoColumnDefs": [{
                            'bSortable': false,
                            'aTargets': [0, 1]
                        }],
                        "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
                        "iDisplayLength": 10,
                    });
    
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    How to increase default datatable_length to all

    Use pageLength and set it to -1.

    Allan

  • brittalpanabrittalpana Posts: 8Questions: 2Answers: 0

    thank you. But two option is not working at the same time. (Print button and datatable_length)Can you please check, is there any error in my above code?

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    Why are you initialising the same DataTable twice? Why not just do it once?

    The code above creates a DataTable with TableTools, then destroys it and replaces it with a DataTable that doesn't use TableTools. I don't see why you would want to do that.

    Allan

  • brittalpanabrittalpana Posts: 8Questions: 2Answers: 0

    How can I use print button and datatable_length for the same table? Only one is working for me. Can you please give an example.

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    What is wrong with Allan's answer?

  • brittalpanabrittalpana Posts: 8Questions: 2Answers: 0

    Nothing but I am requesting him to give an example code for using print button and datatable_length to all at the same time. I can not understand how to use print button code and datatable_length code in a same function. As a result I requesting him to give an code example that how can I use these two code in a same function. I am novice one. Please help me.

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Answer ✓
    $(document).ready(function() {
        $('#example').DataTable( {
            "dom": '<"H"Tlfr>t<"F"ip>',
            "tableTools": {
                "aButtons": [
                    "print",
                    {
                        "sExtends":    "Print",
                         
                    }
                ]
            },
                        "bJQueryUI": true,
                        "aoColumnDefs": [{
                            'bSortable': false,
                            'aTargets': [0, 1]
                        }],
                        "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
                        "iDisplayLength": 10,
                    });
    

    I'm not entirely sure what the problem is with just combining the two. You already have multiple parameters in each of your initialisations.

    Allan

  • brittalpanabrittalpana Posts: 8Questions: 2Answers: 0

    Thank you very much

This discussion has been closed.