Datatbles - switching pages when table is being updated?

Datatbles - switching pages when table is being updated?

northmoornorthmoor Posts: 10Questions: 5Answers: 0

I'm looking for some advice before I go further into what might be an unsolvable problem. I have a table that is updated frequently, in real-time, using web-sockets. So, some data arrives via websockets, and one of the things that is used for is to update a datatable (both inserting new rows and updating existing rows). These updates are very frequent, potentially once a second or so. When my table grows to over 10 rows, and spills over to two pages, the view I see in datatables is what I would expect, e.g. I can see "showing 1 to 10 of 11 entries" and I can see buttons for two pages. However, if I try to move to the second page, either it does not work, or it immediately takes me back to the first page (I'm not sure which, although I suspect it's the latter).

So, I'm wondering if this is known/expected behaviour if you are trying to interact with a table that is simultaneously being updated? If it makes any difference I'm using either row.add or row.data to update the table, depending on whether it's a new row or an update to an existing row.

Before I try to create a test case that can demonstrate the problem, it would be very helpful if anyone knows if what I am seeing is the correct behaviour and hence I need to find some other solution? Or of course if anyone has the same use case as me (very frequent real-time table updates).

Many thanks

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 14,171Questions: 25Answers: 3,343
    Answer ✓

    Just guessing that you are adding the table data using row.add() and using draw() to update the table. You can pass a parameter into the draw() API to control the paging. Try using false, ie, row.add( myRowData ).draw(false);. If this doesn't help then please provide information of how you are adding the rows.

    Also you may be interested in the Scroller extension to eliminate the need for using the paging buttons.

    Kevin

  • northmoornorthmoor Posts: 10Questions: 5Answers: 0

    I managed to tie the issue down a little more. I have set up a test where my table is updated once every 5 seconds with an insert of a new row. After the table grows to 11 rows, I switch to page 2 and watch the table. After the next insert is made, the table is switched back to show page 1. Is there a solution for this? I can create a test example if it's needed.

  • northmoornorthmoor Posts: 10Questions: 5Answers: 0

    Thanks, adding the false parameter to draw sorted it for me, much appreciate the quick response!

Sign In or Register to comment.