{hero}

createdRow

Since: DataTables 1.10

Callback for whenever a TR element is created for the table's body.

Description

This callback is executed when a TR element is created (and all TD child elements have been inserted), or registered if using a DOM source, allowing manipulation of the TR element.

This is particularly useful when using deferred rendering (deferRender) or server-side processing (serverSide) so you can add events, class name information or otherwise format the row when it is created.

Type

function createdRow( row, data, dataIndex, cells )

Parameters:

Example

Add a class to the row, conditionally based on the row's data:

new DataTable('#myTable', {
	createdRow: function (row, data, dataIndex) {
		if (data[4] == 'A') {
			$(row).addClass('important');
		}
	}
});

Related

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