New API methods
New API methods
In general, I'd like to say that the new API is great - though I sometimes struggle to find the new API equivalents for things I have already implemented.
Thus data() appears to be the equivalent to fnGetData(), and I am assuming that all the old functions have a new equivalent.
I currently need to update data in a hidden column (col 0), and the data changes need to be reflected for searching.
The only way I could find is to use fnUpdate(), in a clumsy mix of old & new API:
var indeces = oTable.api().rows().indexes()
for ( var i=0; i<indeces.length; i++ )
{
var row_data = oTable.api().row( indeces[i] ).data()
if ( row_data[0] != new_cell_data )
oTable.fnUpdate( new_cell_data, indeces[i], 0, false, false )
}
oTable.api().draw()
Could you suggest a cleaner soln - perhaps using new API instead of fnUpdate?
A side-effect of fnUpdate seems to be that it destroys existing event bindings on
all cells of the updated row. Is this avoidable?
What would be great is a sort of cheat - sheet, a 2 col table giving equivalents of common tasks in new & old APIs.
Replies
http://datatables.net/upgrade/1.10-convert
Not if the event handlers are attached to the elements inside the cells, since the
innerHTML
is written to. You could use a delegated event on thetbody
, which is what I typically do myself.For your code - a shorter version using the new API only would be:
Allan
Excellent - the cheat-sheet is great (just wish I'd found it earlier), as is the code snippet & event delegation hint.
Thank you gentlemen.