{hero}

rows().invalidate()

Since: DataTables 1.10

Invalidate the data held in DataTables for the selected rows.

Description

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() and cell().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.

Type

function rows().invalidate( [ source ] )

Description:

Invalidate information in the selected rows

Parameters:
Returns:

DataTables API instance with selected row references in the result set

Examples

Modify a cell's content using jQuery and then invalidate the row held by DataTables:

var table = new DataTable('#myTable');
var tr = $('#example tbody tr:eq(0)');

tr.find('td:eq(0)').html('Updated');
table
	.rows(tr)
	.invalidate()
	.draw();

Using a data object instances and invalidate to update the table after external data changes:

var pupils = [new Pupil(), new Pupil(), new Pupil(), new Pupil()];

// Create table with data set
var table = new DataTable('#myTable', {
	data: pupils
});

// Modify the data in the data set
pupils[0].name('Fred Green');
pupils[3].name('Fiona Wilder');

// Invalidate and redraw all rows
table
	.rows()
	.invalidate()
	.draw();

Related

The following options are directly related and may also be useful in your application development.