Add rows without drawing entire table
Add rows without drawing entire table
Hello,
My data table load first chunk of data from server. When 2nd chunk load I add rows and draw table. It works in this way until last chunk. (I have around 50,000+ records and chunk size is 250)
Problem is
If I am working on 100th record on 3rd page table.draw() function draw entire table and redirect me to first page.
What I want is...
Table should load new chunk without affecting my current page and position.
Thanks in advance
This question has an accepted answers - jump to answer
Answers
The
draw()
API has options to stay on the current page. one of them would look like this:table.draw(false);
Does this help with what you are trying to do?
Kevin
Hello @kthorngren ,
I already used draw(false) function but it is not useful.
To maintain same page i used fnStandingRedraw it works fine.
But how to maintain scroll position on same page?
fnStandingRedraw is a legacy API method for DataTables 1.9 and earlier. The
draw()
method Kevin suggested is basically its replacement.If it isn't working for you, please link to a test case showing the issue so we can check it out.
I presume you have scrolling enabled as well as paging in the table (your post doesn't actually say, but from the question this is what I presume - this is why a test case is required, so we know how you are using DataTables). If so, then you'd need to read the
scrollTop
position of the scrolling element before your redraw and then set it after the table has drawn again.Allan
Thanks @allan ,
Y'day, exactly I did the same and it works for me. Will update example soon.
Hello @allan ,
is there any way to add new rows to table without drawing entire table?
No - displaying a row (old or new) requires that all rows on display be drawn again. It should be possible to hold the position in the paging so the end user can't "see" the table being redrawn though.
Allan