DataTables pagination problems
DataTables pagination problems
Hi,
I'm using DataTables server-side processing along with filtering, sorting, row callbacks, hidden columns, etc. The plugin is great and has worked well for the most part so far but I am having some problems getting pagination to work properly.
The first page of the DataTable always works fine with the correct number of displayed rows and the offset starting at 0. Using the pagination buttons below the table is where bad things start to occur.
With a show 10 entries, page 1, I get iDisplayLength = 10 and iDisplayStart = 0. The sInfo says "Showing 1 to 10 of 21 entries".
Loading the 2nd page things change drastically. iDisplayLength = 10 still but iDisplayStart = 010. The sInfo in addition changes to "Showing 0101 to 11 of 11 entries (filtered from 21 total entries)".
After having a look at pretty much every example, usage page, and many forum threads in the process of building this DataTable (and now troubleshooting the pagination) I am at a loss as to what would be causing this odd behavior. I would be happy to pm some of the code I have used if needed. Any insights or relevant threads would be appreciated.
Thanks in advance.
I'm using DataTables server-side processing along with filtering, sorting, row callbacks, hidden columns, etc. The plugin is great and has worked well for the most part so far but I am having some problems getting pagination to work properly.
The first page of the DataTable always works fine with the correct number of displayed rows and the offset starting at 0. Using the pagination buttons below the table is where bad things start to occur.
With a show 10 entries, page 1, I get iDisplayLength = 10 and iDisplayStart = 0. The sInfo says "Showing 1 to 10 of 21 entries".
Loading the 2nd page things change drastically. iDisplayLength = 10 still but iDisplayStart = 010. The sInfo in addition changes to "Showing 0101 to 11 of 11 entries (filtered from 21 total entries)".
After having a look at pretty much every example, usage page, and many forum threads in the process of building this DataTable (and now troubleshooting the pagination) I am at a loss as to what would be causing this odd behavior. I would be happy to pm some of the code I have used if needed. Any insights or relevant threads would be appreciated.
Thanks in advance.
This discussion has been closed.
Replies
Allan
Any other ideas on where DataTables would be doing something like that?
If it helps, Firebug shows the XHR Get request sent on the "go to 2nd page of table" request sends through the 010 value for iDisplayStart. Any way that I could be manipulating that incorrectly that early on?
Cheers for the first thought anyways.
Thanks,
Allan
Thanks for the help anyways.
:)
I am facing the same issue where in I have a text field where in the user can give the results limit to be displayed in the page.
1) First time user types 10 in the text field eg results are displayed fine and the sInfo shown properly
eg
Showing 1 to 10 of 217 entries
FirstPrevious12345NextLast
2)User clicks on the next link and next 10 records are displayed but sInfo changes to below text.
This is strange as ideally sInfo should be,"showing 10 to 20 of 217 entries".
Please let me know if you know the solution for this.I am using datatables 1.9
Showing 0101 to 217 of 217 entries
FirstPrevious12345NextLast
Regards
Gaurav
Allan
ps. Please don't post your question in multiple threads - it gets very confusing and means sone threads don;t have answers for future users who find the thread by search.
Backup your jquery.dataTables.js file. Find these lines starting from line 2938 in jquery.dataTables.js, version 1.9.4:
[code]
if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
{
oSettings._iDisplayStart += oSettings._iDisplayLength;
}
[/code]
Replace this to:
[code]
oSettings._iDisplayStart=parseInt(oSettings._iDisplayStart);
oSettings._iDisplayLength=parseInt(oSettings._iDisplayLength);
if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
{
oSettings._iDisplayStart += parseInt(oSettings._iDisplayLength);
}
[/code]
Tested OK so far...
Same file, line 11382:
Alter this:
[code]
return Math.min( this._iDisplayStart+this._iDisplayLength,
this._iRecordsDisplay );
[/code]
To:
[code]
return Math.min( this._iDisplayStart+parseInt(this._iDisplayLength),
this._iRecordsDisplay );
[/code]