How do I rotate pagination automatically every 10 seconds on a table?


Screenshot 2024-02-14 at 3.07.54 PM

I have a table as shown above and I am using client-side pagination with a pagesize of 10. I want the pagination to rotate from the first page to 2nd after 10 seconds and then to the 3rd and so on automatically. Once it reaches the last page, it should start over with the first page. The purpose is to display this on a TV for my team, such that they can monitor the data without any interaction.

I have tried writing a small function to do so and I’m calling this function repeatedly every 10 seconds (through advanced settings).

In the above code I think two things are wrong, table.refresh() refreshes the entire data and hence every time the currentPage value is 1 and it remains static.

Secondly, I think table1.pagination.currentPage = newPage, the newPage value cannot be assigned to thr current Page value as it only returns the number, currentPage cannot do any action with the input.

Current Page 0

But irrespective of my approach, let me know if there’s any other solution to this.

Hi, welcome to the community

What you're doing sounds correct and using the "run periodically" in advanced settings is a good choice.

The table has a setPage function that you could use here. Something like:

let maxPage = Math.ceil(table1.data.length / table1.pagination.pageSize);

let nextPage = table1.pagination.currentPage+1;

nextPage = (nextPage<maxPage) ? nextPage : 0;

table1.setPage(nextPage);

The Pagination object doesn't expose the total pages, just the number of records on each page (pageSize) so you have to calculate that part yourself to loop back to page 1 if you've reached the last page.

Yes, this works. Thank you!