Multiple issues with pagination
Multiple issues with pagination
I am facing multiple issues with pagination in my table.
1. Even when the number of records to show is selected as 10 at the top of the table using the drop down box, the table is displaying more than 10 records.
2. I have used the init option sPaginationType: "full_numbers" - so by default 5 page numbers are displayed. Even when all my records are shown in page one itself, other pages (page 2,3,4 and 5) are enabled. On clicking page 2, "Processing..." message is shown and the same data in first page is loaded again in page 2. This happens for any number of sucessive pages infinitely.
3. Even though 'Next' button appears enabled, it doesn't work.
4. When 'Last' button is clicked, all numbered pages disappear i.e., Only 'First', 'Previous', 'Next' and 'Last' buttons are displayed, and these buttons are enabled and clickable.
5. Now when I click 'First' button all pagination buttons are displayed (even the numbered pages between 'Previous' and 'Next') again as it was during the initial load.
I believe these problems are related to one another. I think I am missing something which leads to a series of problems.
Below is the code I am using. I am using DataTables 1.9.4 with jQuery 1.8.1
Thanks for your patience and time.
[code]
oTable = $("#data-table-id").dataTable({
bJQueryUI: true,
bRetrieve: false,
bDestroy: true,
bPaginate: true,
sPaginationType: "full_numbers",
bFilter: false,
bInfo: false,
aoColumnDefs: [
{ "bSortable": false, "aTargets": [ 0 ] },
{ "bSortable": false, "aTargets": [ 4 ] }
],
bProcessing: true,
bServerSide: true,
sAjaxSource : myURL,
fnServerParams: function ( aoData ) {
aoData.push( {"name":"param1" , "value": "paramValue1"},
{"name":"param2" , "value": "paramValue2"});
},
aoColumns: [
{ "mData": "checkbox" },
{ "mData": "col2" },
{ "mData": "col3" },
{ "mData": "col4" },
{ "mData": "col5" },
{ "mData": "hidden_error_flag" },
],
"fnInitComplete": function(){
$('td:nth-child(6),th:nth-child(6)').hide(); // to hide the error flag column
$('#data-table-body-id td:nth-child(1)').addClass("align-center"); // to align the checkbox in the first column to center
}
});
[/code]
1. Even when the number of records to show is selected as 10 at the top of the table using the drop down box, the table is displaying more than 10 records.
2. I have used the init option sPaginationType: "full_numbers" - so by default 5 page numbers are displayed. Even when all my records are shown in page one itself, other pages (page 2,3,4 and 5) are enabled. On clicking page 2, "Processing..." message is shown and the same data in first page is loaded again in page 2. This happens for any number of sucessive pages infinitely.
3. Even though 'Next' button appears enabled, it doesn't work.
4. When 'Last' button is clicked, all numbered pages disappear i.e., Only 'First', 'Previous', 'Next' and 'Last' buttons are displayed, and these buttons are enabled and clickable.
5. Now when I click 'First' button all pagination buttons are displayed (even the numbered pages between 'Previous' and 'Next') again as it was during the initial load.
I believe these problems are related to one another. I think I am missing something which leads to a series of problems.
Below is the code I am using. I am using DataTables 1.9.4 with jQuery 1.8.1
Thanks for your patience and time.
[code]
oTable = $("#data-table-id").dataTable({
bJQueryUI: true,
bRetrieve: false,
bDestroy: true,
bPaginate: true,
sPaginationType: "full_numbers",
bFilter: false,
bInfo: false,
aoColumnDefs: [
{ "bSortable": false, "aTargets": [ 0 ] },
{ "bSortable": false, "aTargets": [ 4 ] }
],
bProcessing: true,
bServerSide: true,
sAjaxSource : myURL,
fnServerParams: function ( aoData ) {
aoData.push( {"name":"param1" , "value": "paramValue1"},
{"name":"param2" , "value": "paramValue2"});
},
aoColumns: [
{ "mData": "checkbox" },
{ "mData": "col2" },
{ "mData": "col3" },
{ "mData": "col4" },
{ "mData": "col5" },
{ "mData": "hidden_error_flag" },
],
"fnInitComplete": function(){
$('td:nth-child(6),th:nth-child(6)').hide(); // to hide the error flag column
$('#data-table-body-id td:nth-child(1)').addClass("align-center"); // to align the checkbox in the first column to center
}
});
[/code]
This discussion has been closed.
Replies
Thanks!
Please link to a test case: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read
Allan
Thanks for your time!
Setting bServerSide as 'false' worked. Apart from pagination it also fixed the issue with sorting.