default table display length and options

default table display length and options

johnjohn Posts: 2Questions: 0Answers: 0
edited November 2009 in General
I am just starting to use datatables. It is fantastic. I would like to be able to pass the number of entries select box as an array so I can customize the display length options. Also passing the default display length would be good - let me set it rather than hard code it at 10 - 20 or 25 is often better than 10.

I have hacked these changes into my version of datatables - but it's not production quality.

Replies

  • izzy6150izzy6150 Posts: 49Questions: 0Answers: 0
    Hi,

    There has been a previous post on here about this. Not sure where it is tho. Here is the solution for what you wanted that has been adopted by some.
    around line 926 ish (in with the setting variables) enter the following:
    [code]
    /*
    * Variable: aPaginationLengths
    * Purpose: The different lengths available for pagination
    * Scope: jQuery.dataTable.classSettings
    */
    this.aPaginationLengths = [10,25,50,100];
    [/code]

    in _fnFeatureHtmlLength ( oSettings ) change the select box to be this:
    [code]
    var sStdMenu =
    '';
    for( var i=0 ; i
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Hi guys,

    Yup - there is actually a method to do this in DataTables already. If you using the internationalisation option oLanguage.sLengthMenu ( http://datatables.net/usage/i18n#oLanguage.sLengthMenu ) you can give it whatever values you want (even -1 which is a magic "show all" value).

    Regards,
    Allan
  • johnjohn Posts: 2Questions: 0Answers: 0
    Great! Thanks for the help.
  • ymagasheymagashe Posts: 20Questions: 0Answers: 0
    Hello Allan,

    Thanks for the 'Show All' option in menu. It's really helpful.

    Regards,
    Yogesh
This discussion has been closed.