Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

keep pagination state on fnDraw()

I am using jquery datatables in my application. I have a problem with my pagination, it is resetting when I use this.table.dataTable().fnDraw().

For every 5 seconds my datatable calls fnDraw() while updating the table. When this.table.dataTable().fnDraw() is called first page is displayed, even if the user is on page 2 or other.

Is there an way to keep the pagination state even after this.table.dataTable().fnDraw().

like image 520
user1181892 Avatar asked May 15 '12 05:05

user1181892


2 Answers

On http://datatables.net/ref the explanation for fnDraw says:

Parameter:  fnDraw
Type:       function
Inputs:     {bool} [default=true]: Re-filter and resort 
            (if enabled) the table before the draw.

So, just tried this.table.dataTable().fnDraw(false) and it worked. Stayed on the same page and also sorting stayed the same.

like image 167
DKSan Avatar answered Nov 14 '22 01:11

DKSan


Have a look at this plugin which does what you want: http://datatables.net/plug-ins/api#fnStandingRedraw

like image 5
Allan Jardine Avatar answered Nov 14 '22 01:11

Allan Jardine