fnDraw without resetting pagination

fnDraw without resetting pagination

mariusc80mariusc80 Posts: 1Questions: 0Answers: 0
edited September 2012 in DataTables 1.9
I'm using 1.9.4 with server side data from a ASP.Net Web service.
I'm also using the fnDraw() method as means for forcing refresh.

Currently the fnDraw tries to use oSettings.iInitDisplayStart to get the page number before refresh, but the value is set only in _fnInitialise() and _fnLoadState(). So if you refresh the page it works ... but if you do a ajax refresh ... back to initial page.

To 'solve' this I changed:
[code]
this.fnDraw = function( bComplete )
{
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );
if ( bComplete === false )
{
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
}
else
{
_fnReDraw( oSettings );
}
};
[/code]

to

[code]
this.fnDraw = function( bComplete )
{
var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] );

// Save the page status on redraw
if (oSettings.oFeatures.bStateSave)
{
oSettings.iInitDisplayStart = oSettings._iDisplayStart;
}

if ( bComplete === false )
{
_fnCalculateEnd( oSettings );
_fnDraw( oSettings );
}
else
{
_fnReDraw( oSettings );
}
};
[/code]

Don't know if the current functionality is a feature.

I also read http://datatables.net/forums/discussion/1309/fndraw-without-resetting-pagination/p1

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes, the current functionality is a feature since it matches how DataTables behaves with client-side processing. However, I do acknowledge that it isn't always the behaviour that is wanted and I'm planning to introduce a standing redraw method as part of the API rework for v1.10.

    Allan
  • streetlightstreetlight Posts: 26Questions: 0Answers: 0
    I changed with to no avail in 1.7.6. Any reason why you could see this not working?
This discussion has been closed.