Server sort bug wrt iDisplayStart

Server sort bug wrt iDisplayStart

idbillidbill Posts: 1Questions: 0Answers: 0
edited May 2012 in General
Say I have 13 items, and 10 items are shown per page.
There is a sort field that will hide 4 of those items, but isn't currently checked.

When I go to page 2, the display line shows 'Showing 11 to 13 of 13 items'.
When I hide those 4 items, the page shows up as blank!

On the server side, I now check to see if nothing is shown, and force the filter to start at 0.
Now Datatables displays 'Showing 11 to 9 of 9 items'!?!

But for some weird reason, when fnDraw() is called a second time, datatables works itself out. Why can't it do it right the first time?

ugh.

I tried passing iDisplayStart back in the json response, but that is ignored... nor can I actually modify that value on the fly.

In the code below you'll see I've added 'fnServerData' just to check for this scenario, but it causes a double search.

Any better solutions would be appreciated,
Bill

code is below uses Datatables 1.8.1
[code]
table = $( '#table' ).dataTable( {
'aLengthMenu': [[5, 10, 25, -1], [5, 10, 25, "All"]],
'aoColumns': [ { "asSorting": [ "desc" ],
"bSearchable": true,
"bVisible": true,
"sType": "date" } ],
'bAutoWidth': false, // remove width css
'bFilter': true, //add search box
'bJQueryUI': false,
'bPaginate': true,
'bSearch':true,
'bProcessing': true,
"oLanguage": {
"sSearch": ""
},
'bServerSide': true,
'sAjaxSource': '/dashboard/',
'bSort': false,
'fnServerData': function( sSource, aoData, fnCallback ) {
$.getJSON( sSource, aoData, function( json ) {
/* Do stuff */
fnCallback( json );
var oSettings = table.fnSettings();
if ( oSettings._iDisplayStart > json.iTotalRecords ) {
table.fnDraw();
}
} );
},
'sAjaxSource': "/dashboard/",
'sPaginationType': 'two_button',
'sDom': '<"top"fpi>rt<"bottom"lpi><"clear">'
} );
[/code]

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Firstly can you try with the latest DataTables version (1.9.1) to see if that addresses the issue?

    Secondly, DataTables should be resetting the paging when you type something into the filter - and that does happen in my demo here: http://datatables.net/release-datatables/examples/data_sources/server_side.html .

    If 1.9.1 doesn't fix the problem, can you give me a link to the page please?

    Allan
This discussion has been closed.