keep pagination state on fnDraw()

大城市里の小女人 提交于 2021-02-18 05:01:29

问题


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().


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/10594466/keep-pagination-state-on-fndraw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!