iDisplayStart with bServerSide

iDisplayStart with bServerSide

koalakoala Posts: 1Questions: 0Answers: 0
edited November 2013 in Bug reports
Hi all!

I don't know exactly if it is a bug or not. I've spent several hours and got it worked.
My aim was to save state of my datatable with hash in address bar (it is sometimes iseful, you know)

Finally i wrote this function:
function setTable() {
if (!just_drawn)
var hSettings = $.deparam.fragment();
var cSettings = oTable.fnSettings();
cSettings.iInitDisplayStart = hSettings.offset === undefined ? 0 : parseInt(hSettings.offset);
cSettings._iDisplayStart = hSettings.offset === undefined ? 0 : parseInt(hSettings.offset);
$(window).bind('hashchange', setTable);
just_drawn is a global var that helps me to prevent loops.

The point is that iInitDisplayStart is not described anywhere, i found it in source code (thanks for non-minified version), but one must use it if his oTable defined with bServerSide = true. It caused by these lines of datatables code, i think:
/* Check and see if we have an initial draw position from state saving */
if ( oSettings.iInitDisplayStart !== undefined && oSettings.iInitDisplayStart != -1 )
if ( oSettings.oFeatures.bServerSide )
oSettings._iDisplayStart = oSettings.iInitDisplayStart;
oSettings._iDisplayStart = (oSettings.iInitDisplayStart >= oSettings.fnRecordsDisplay()) ?
0 : oSettings.iInitDisplayStart;
oSettings.iInitDisplayStart = -1;
_fnCalculateEnd( oSettings );

All this stuff is looking very confusing, probably there is some way to patch it?

Nevertheless, thank you for really great plugin!

P.S. btw, integration with bbq was also quite tricky (because of loops, mainly) and i still have not realized all of the reasons. I think, it would be very useful to create the plugin for such integration or include it in next version.


  • allanallan Posts: 58,315Questions: 1Answers: 9,332 Site admin
    The settings object in DataTables (fnSettings / oSettings) is considered to be private, and shouldn't generally be manipulated externally. That's why its properties aren't well documented - its not an API.

    Having said that, DataTables 1.10 has a new API method called `page()` which can be used to set the display start point if you need to. I'm still writing the documentation for 1.10 though...

    Also there is actually a plug-in for setting the display start in 1.9 already:

This discussion has been closed.