fnDraw appears to be asynchronous.
fnDraw appears to be asynchronous.
I am trying to delete some rows on the server, then redraw my table, then get the number of rows remaining in the table. I am using server-side processing.
[code]
oTable.fnStandingRedraw();
var numRows = oTable.fnSettings().fnRecordsTotal();
...
[/code]
The problem is that my numRows is calculated before the table is redrawn, so it displays the number of rows prior to this operation. Is there a way to wait until the table is redrawn before getting the number of rows?
[code]
oTable.fnStandingRedraw();
var numRows = oTable.fnSettings().fnRecordsTotal();
...
[/code]
The problem is that my numRows is calculated before the table is redrawn, so it displays the number of rows prior to this operation. Is there a way to wait until the table is redrawn before getting the number of rows?
This discussion has been closed.
Replies
What you can do is listen for the 'draw' event that DataTables fires:
[code]
$(myTableSelector).one('draw', function () {
... number calculation;
} );
[/code]
The jQuery 'one' method is very handy for situations such as this, where yo want to listen for the event once and then detect the listener - jQuery does that later part for you :-)
Allan
-Ben
Regards,
Allan