rows().data()

Since: DataTables 1.10

Get the data for the selected rows.

Description

This method is used to get the data used for the cells in the rows matched by the selector from DataTables.

The order of the data in the returned array and which rows the data is obtained from (searched rows, visible rows etc) is controlled by the selector-modifier option of the rows() selector used to get the selected rows.

This method cannot be used to modify data in the table, only to retrieve it. Use the row().data() method instead which can be used as a setter.

Type

function rows().data()

Description:

Get the data for the rows from the selector

Returns:

DataTables API instance with data for each row from the selector in the result set. Each entry is the original data source object for that row, be it an array, object or Javascript object instance.

Examples

Get all data from the table:

var table = $('#example').DataTable();

var data = table
	.rows()
	.data();

alert( 'The table has '+data.length+' records' );

Using a data object instances as the data source:

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

// Create table with data set
var table = $('#example').DataTable( {
	data: pupils
} );

var rows = table.rows( 0 ).data();

alert( 'Pupil name in the first row is: '+ rows[0].name() );

Related

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