Suggested Code Addition for Variable Pagination Lengths
Suggested Code Addition for Variable Pagination Lengths
Instead of hardcoded pagination lengths (I needed specific page length options), maybe this should become a variable? I modified the following code and it works pretty well:
Added this under the this.aoColumns = []; definition (around line 921 or so):
[code]
/*
* Variable: aPaginationLengths
* Purpose: The different lengths available for pagination
* Scope: jQuery.dataTable.classSettings
*/
this.aPaginationLengths = [10,25,50,100];
[/code]
Inside the function _fnFeatureHtmlLength, I changed the sStdMenu variable definition to:
[code]
var sStdMenu =
'';
for( var i=0 ; i
Added this under the this.aoColumns = []; definition (around line 921 or so):
[code]
/*
* Variable: aPaginationLengths
* Purpose: The different lengths available for pagination
* Scope: jQuery.dataTable.classSettings
*/
this.aPaginationLengths = [10,25,50,100];
[/code]
Inside the function _fnFeatureHtmlLength, I changed the sStdMenu variable definition to:
[code]
var sStdMenu =
'';
for( var i=0 ; i
This discussion has been closed.
Replies
Or you could use the oLanguage.sLengthMenu parameter: http://datatables.net/usage/i18n#oLanguage.sLengthMenu . There is even an example showing how it could be done :-). Regardless, thanks for sharing your solution with us - it looks like quite a nice way of doing it.
Regards,
Allan
[code]
var oSettings = dataTable.fnSettings();
oSettings._iDisplayLength = 100;
dataTable.fnDraw();
[/code]
Just after: var dataTable = $('.DataTableGridView').dataTable(); block. But the user still sees that there are 10 rows and afterwards there are more. The problem is that we have only list of 50, 100, 250 and "all" in drop down by changing language variable since 10 is just too small for us.
Is it possible to define default value for startup somewhere at setup?
You can just use the iDisplayLength ( http://datatables.net/usage/options#iDisplayLength ) initialisation property to set the number of records to be shown on a page at initialisation. This will work correctly with the drop down menu as well (as long as you have either defined your custom value in the menu, or it is one of the defaults).
Regards,
Allan