iDisplayStart greater than displayed records using ServerSide and Filters
iDisplayStart greater than displayed records using ServerSide and Filters
Luvpascal
Posts: 1Questions: 0Answers: 0
I've been evaluating Datatables 1.9.1 and I think I've found a possible bug. My code uses bServerSide to get the data and that all works fine. But, when I am filtering, I can cause that first value in the record count to be larger than the current filtered result set. An example of this is show in the record count display:
Showing 21 to 4 of 4 entries (filtered from 200 total entries)
This happens when I do the following:
1) Search on something that causes pagination, so for example, my first query will return 50 filtered records and I'll get:
Showing 1 to 20 of 50 entries (filtered from 200 total entries)
2) Click to a page number greater than the current page. In the example below, I click on Page 2 and get:
Showing 21 to 40 of 50 entries (filtered from 200 total entries)
3) Then, I type in a different string to filter on that only returns 4 records, and I get:
Showing 21 to 4 of 4 entries (filtered from 200 total entries)
As far as I can figure out, when iDisplayStart is greater than the total filtered record count, this will happen.
So, I used firebug to look through and debug the _fnDraw routine in the source, and I modified the code around line 1325 as follows:
if (oSettings.oFeatures.bServerSide)
{
iStart = 0;
iEnd = oSettings.aoData.length;
/* Added this... */
if (oSettings._iDisplayStart > oSettings.fnRecordsDisplay()) {
oSettings._iDisplayStart = 0;
oSettings._iDisplayEnd = iEnd;
}
/* ...Added this */
}
Please let me know if I've just completely missed something, or not.
Thanks!
Showing 21 to 4 of 4 entries (filtered from 200 total entries)
This happens when I do the following:
1) Search on something that causes pagination, so for example, my first query will return 50 filtered records and I'll get:
Showing 1 to 20 of 50 entries (filtered from 200 total entries)
2) Click to a page number greater than the current page. In the example below, I click on Page 2 and get:
Showing 21 to 40 of 50 entries (filtered from 200 total entries)
3) Then, I type in a different string to filter on that only returns 4 records, and I get:
Showing 21 to 4 of 4 entries (filtered from 200 total entries)
As far as I can figure out, when iDisplayStart is greater than the total filtered record count, this will happen.
So, I used firebug to look through and debug the _fnDraw routine in the source, and I modified the code around line 1325 as follows:
if (oSettings.oFeatures.bServerSide)
{
iStart = 0;
iEnd = oSettings.aoData.length;
/* Added this... */
if (oSettings._iDisplayStart > oSettings.fnRecordsDisplay()) {
oSettings._iDisplayStart = 0;
oSettings._iDisplayEnd = iEnd;
}
/* ...Added this */
}
Please let me know if I've just completely missed something, or not.
Thanks!
This discussion has been closed.