Invalidate the data held in DataTables for the selected cells.
DataTables holds cached information about the contents of each cell in the table to increase performance of table operations such as ordering and searching. If you were to modify the contents of a cell (for DOM data source tables) or the array / object values (for Ajax / JS source tables) DataTables wouldn't know that this has happened. This method can be used to tell DataTables to re-read the information from the data source for the row (be it from the DOM or objects / arrays - whatever the original data source was).
This provides an alternative to using
row().data() when changing cell values. Typically the
data methods are preferred over the invalidation methods, as they use less code, but where the invalidation methods really shine is when the data source for the table are external objects which can be updated using that objects own methods.
Prior to this method actually invalidated the whole row for the selected cells. As of only the cells in question are invalidated.
function cells().invalidate( [ source ] )
Invalidate information in the selected cells
Name Type Optional 1
Yes - default:auto
Data source to read the new data from.
This property can take the values:
auto- use original data source
dom- use the data currently held in the DOM
DataTables API instance with selected cell references in the result set
Modify a cell's content using jQuery and then invalidate the data held by DataTables:
var table = $('#example').DataTable(); var td = $('#example tbody td:eq(0)'); td.html( 'Updated' ); table.cell( td ).invalidate().draw();
The following options are directly related and may also be useful in your application development.