Reputation: 8936
I am using local pagination option on a tabulator table, and I am trying to provide a means of selecting all rows currently displayed on the page, but I can't find a way of determining the rows that are displayed on the current page, is there a way to do that, if so how?
I have looked through the documentation on pagination and the pagination module but the closest thing I have found is .selectRow()
, but that selects all rows in the tabulator, not just the current page.
http://tabulator.info/docs/4.2/page
http://tabulator.info/docs/4.2/modules#module-page
Upvotes: 1
Views: 1129
Reputation: 8936
const rows = this.tabulator.getRows(true); // returns array of all the currently filtered/sorted elements
const currentPage = this.tabulator.getPage(); // returns the current page
const pageSize = this.tabulator.getPageSize(); // returns the current number of items per page
const start = (currentPage - 1) * pageSize; //start index
// figure out end index, taking into account last page may not be full
if (rows.length < currentPage * pageSize) {
end = start + (rows.length % pageSize);
} else {
end = start + pageSize;
}
for (let index = start;index < end;index++) {
rows[index].select();
}
Upvotes: 1