scroller.page()

Since: Scroller 1.4.1

Get information about the rows that are currently being displayed. Please note - this property requires the Scroller extension for DataTables.

Description

It can often be useful to know what rows are being displayed in a DataTable, but this is made a bit harder in a table with Scroller enabled since it will draw only a section of the table's data, and only a part of that data will actually be visible in the viewport. This method makes it possible to know what the display indexes of the shows show are.

It is important to note that these indexes are 0 based - i.e. the first row in the table is index 0. Also the indexes are in display order and do not directly map to the data index. Use the :eq() operator to select rows (row()) based on display order (see example below).

Type

function scroller.page()

Description:

Determine the display index of the top and bottom most visible rows in the DataTable (this includes partially visible rows).

Returns:

An object with the parameters start and end, defining the start and end, 0 based, display indexes of the rows that are visible in the table's scrolling viewport.

Example

Get the data for the first visible row in the table:

var table = $('#myTable').DataTable();
var displayIndexes = table.scroller.page();

var data = table.row( ':eq('+displayIndexes.start+')', {order:'applied', search:'applied'} ).data();

Related

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