how can i activate show all in length menu for server-side processing

how can i activate show all in length menu for server-side processing

ASLASL Posts: 13Questions: 7Answers: 0

Hi,

How can the length menu be changed from 10,25,50,100 to 10,25,50,100 and all?#
I am doing serverside processing and i tried the -1 in lengthmenu - no luck.
Please help me
Thanks in advance

This question has an accepted answers - jump to answer

Answers

  • DirceuNazarethDirceuNazareth Posts: 44Questions: 1Answers: 12

    You may already tried it, but it works for me...

    All is the alias of -1, so if you want 100 and All in the same you need to added the -1 after the 100.

    lengthMenu

    $('#example').dataTable( {
      "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ]
    } );
    

    The docs says:
    2D array which will use the first inner array as the page length values and the second inner array as the displayed options. This is useful for language strings such as 'All').

  • ASLASL Posts: 13Questions: 7Answers: 0

    Does this work when serverside is true??

  • DirceuNazarethDirceuNazareth Posts: 44Questions: 1Answers: 12

    Part of the code that I use...

       "serverSide": true,
        "stateSave": true,
        "paging": true,
        "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ],
        "pagingType": "full_numbers",
        "pageLength": 25,
    
  • ASLASL Posts: 13Questions: 7Answers: 0

    Yes,I did the same way..But it does not work for 'all' alone. It stays as it is, not showing the full list.

    I can't figure what is wrong..
    $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." ";

    This is in my serverside processing page.I guess the -1 is not doing what it has to!

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Does this work when serverside is true??

    If your server-side processing script allows for it, then yes. Basically you need to detect when the length is -1 and not apply the limit. A limit of -1 is duff SQL.

    ALlan

  • ASLASL Posts: 13Questions: 7Answers: 0

    Thank you allan. I got it.

    Thank you DirceuNazareth !

This discussion has been closed.