Multiple issues with pagination

Multiple issues with pagination

Madhu12Madhu12 Posts: 32Questions: 0Answers: 0
edited January 2013 in General
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]

Replies

  • Madhu12Madhu12 Posts: 32Questions: 0Answers: 0
    Any idea where I am going wrong? Really struck up

    Thanks!
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    I would get you've not fully implemented server-side processing - which is required since you've enabled it. http://datatables.net/usage/server-side

    Please link to a test case: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Allan
  • Madhu12Madhu12 Posts: 32Questions: 0Answers: 0
    edited January 2013
    Thanks Allan! From the link provided I learn that I have missed iTotalRecords and iTotalDisplayRecords config options. I am getting data from legacy system which won't be able to interpret these variables. It always sends data as a single chunk. So I think vertical scroll bar is the best option for me.

    Thanks for your time!
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    You can still use paging without server-side processing, just don't enable server-side processing :-)
  • Madhu12Madhu12 Posts: 32Questions: 0Answers: 0
    edited January 2013
    Thanks a ton!!

    Setting bServerSide as 'false' worked. Apart from pagination it also fixed the issue with sorting.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    It would do, since with server-side processing enabled, sorting is done at the server... :-)
  • Madhu12Madhu12 Posts: 32Questions: 0Answers: 0
    Learned a lot about DataTables in past couple of weeks. Thanks for the wonderful documentation and tireless assistance :-) I will keep visiting this forum and help others in need. That way I believe I will reduce at least a bit of your work load :-)
This discussion has been closed.