How to retrieve the data currently visible on the table

How to retrieve the data currently visible on the table

stevelstevel Posts: 8Questions: 0Answers: 0
edited May 2013 in DataTables 1.9
I have a table with 50 rows, and I've chosen the option "Show 10 entries", so only the first 10 records are visible. I haven't applied a filter.

How can I obtain a reference to the 10 currently-visible rows of data (and renew this reference when the user scrolls to the next/previous 10 rows)?

http://www.datatables.net/forums/discussion/10321/fngetdata-of-visible-rows-only/p1 says to use:

[code]var data = oTable._('tr', {"filter":"applied"});[/code]

but this is still showing me all 50 rows. Do I need to use the other suggestion of traversing the nodes:

[code]
var anNodes = $("#example tbody tr");
for (var i = 0; i < anNodes.length; ++i) .....
[/code]

Thanks,
Steve

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Have a look at the docs for the `_` method: http://datatables.net/docs/DataTables/1.9.4/#_ . You can use:

    [code]
    var data = oTable._('tr', {"page":"current"});
    [/code]

    Allan
  • stevelstevel Posts: 8Questions: 0Answers: 0
    thanks Allan
This discussion has been closed.