How can I set the default number of rows that show and the optional number I can select ?
How can I set the default number of rows that show and the optional number I can select ?
I used the following to set up my datatable with version 1.9.2
[code]
var oTable = $('#dataTable').dataTable({
aLengthMenu: [[25, 50, 200, -1], [25, 50, 200, "All"]],
aoColumnDefs: [
{
"sSortDataType": "dom-data-rk", "aTargets": ["sort-data-rk"]
}
],
sDom: '<"block-controls"<"controls-buttons"p>>rti<"block-footer clearfix"lf>',
fnDrawCallback: function () {
this.parent().applyTemplateSetup();
},
fnInitComplete: function () {
$('.dataTables_scroll').addClass("no-margin");
this.parent().applyTemplateSetup();
}
});
[/code]
It seemed to work before and then it gave me all rows by default.
Now it does not do this. What it does is show: "Showing 1 to 10 of 251 entries" and in the select box it shows the number 25.
Can someone tell me if I am doing something wrong and how I can make my datatable default to showing all of the rows which in this case are 251?
[code]
var oTable = $('#dataTable').dataTable({
aLengthMenu: [[25, 50, 200, -1], [25, 50, 200, "All"]],
aoColumnDefs: [
{
"sSortDataType": "dom-data-rk", "aTargets": ["sort-data-rk"]
}
],
sDom: '<"block-controls"<"controls-buttons"p>>rti<"block-footer clearfix"lf>',
fnDrawCallback: function () {
this.parent().applyTemplateSetup();
},
fnInitComplete: function () {
$('.dataTables_scroll').addClass("no-margin");
this.parent().applyTemplateSetup();
}
});
[/code]
It seemed to work before and then it gave me all rows by default.
Now it does not do this. What it does is show: "Showing 1 to 10 of 251 entries" and in the select box it shows the number 25.
Can someone tell me if I am doing something wrong and how I can make my datatable default to showing all of the rows which in this case are 251?
This discussion has been closed.
Replies
the datatables is showing 10 rows at a time because it is its default setting, for you to show all the records try the following while setting up your datatables:
[code]
$(document).ready( function() {
$('#example').dataTable( {
"iDisplayLength": -1
} );
} )
[/code]
also check the following for all the changes possible.
http://www.datatables.net/usage/options
Arjun.