How to preserve selected page size in data tables while refreshing the page.
How to preserve selected page size in data tables while refreshing the page.
umeshvishwa
Posts: 3Questions: 1Answers: 0
I have a data table which has page size (i.e. lenghtmenu 10/25/50/100) and this table has one refresh button which recreate data tables with the data returned from the server using ajax call.
I want to preserve the selected page size when user clicks on refresh button.
Can anyone help me in this as I am new in data tables plugin?
This discussion has been closed.
Answers
Please help me in this ASAP.
By "refresh button which recreate data tables with the data returned from the server using ajax call" do you mean you use the DataTables API method ajax.reload or are you destorying the DataTable and re-initializing it?
Use State Saving, it saves that information http://www.datatables.net/examples/basic_init/state_save.html
When reloading DataTable data you shouldn't need to use state saving unless the page is reloaded.
If his "refresh button" is triggering an AJAX call then it is likely state saving is not going to solve the issue.
Hi Diamian,
I am destroying data table and re-initializing it.
Do not destory the Datatable. Just use the
ajax.reload()
to refresh the table and if you want to keep sorting and page then useajax.reload(false)
.