{hero}

childRow

Since: DataTables 1.11

A child row has been added or removed from the table.

Description

The childRow is triggered whenever a child row is inserted or removed from the table.

Please note that, as with all DataTables emitted events, the event object has a DataTables API instance available on it (the first parameter). Additionally, the events are triggered with the dt namespace. As such, to listen for this event, you must also use the dt namespace by simply appending .dt to your event name, as shown in the example below. The listener should also be set before the table initialisation, otherwise when a state is attempting to load, the listener will not be set and the code will not run for the initial display of child rows.

Type

function function( e, show, row )

Parameters:

Example

Notification on child row display change:

let table = new DataTable('#myTable', {
	ajax: '../ajax/data/objects.txt',
	rowId: 'id',
	stateSave: true,
	columns: [
		{
			className: 'dt-control',
			orderable: false,
			data: null,
			defaultContent: ''
		},
		{ data: 'name' },
		{ data: 'position' },
		{ data: 'office' },
		{ data: 'salary' }
	],
	order: [[1, 'asc']]
});

table.on('childRow.dt', function (e, show, row) {
	console.log((show ? 'Showing ' : 'Hiding ') + 'row ' + row.index());
});