{hero}

get()

Since: DataTables 2.0.0

Get the underlying data from a DataTable instance.

Description

This method provides access to the data that is contained within a DataTables API instance. The DataTables API is array-like so it is possible to access the data using array notation, but it can also be useful to use the API to more explicitly state what is happening in the code (i.e. making it more readable). It is based upon the jQuery method of the same name.

Please note that initially this method may appear to be similar to the eq() method, but the data the two methods operate on is different:

  • eq() selects a specific DataTable from an API instance that references multiple tables
  • get() gets the data from the API instance.

Type

function get( idx )

Description:

Get the data from a given index in a DataTables API instance.

Parameters:
Returns:

Any

The data from the given index. undefined is returned if the data doesn't exist at the given index.

Examples

Get the data from the top cell in the second column, taking into account current sorting:

var table = new DataTable('#myTable');
var cellData = table
	.column(2, { order: 'applied' })
	.data()
	.get(0);

// Note that the above is functionally the same as:
// table.column(2, {order: 'applied'}).data()[0]

Get the data for the first row in the table:

var table = new DataTable('#myTable');

table
	.rows()
	.data()
	.get(0);

// Again, this is functionally the same as:
// table.rows().data()[0]

Related

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