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.

umeshvishwaumeshvishwa 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?

Answers

  • umeshvishwaumeshvishwa Posts: 3Questions: 1Answers: 0

    Please help me in this ASAP.

  • DaimianDaimian Posts: 62Questions: 1Answers: 15

    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?

  • anaganag Posts: 48Questions: 2Answers: 7

    Use State Saving, it saves that information http://www.datatables.net/examples/basic_init/state_save.html

  • DaimianDaimian Posts: 62Questions: 1Answers: 15

    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.

  • umeshvishwaumeshvishwa Posts: 3Questions: 1Answers: 0

    Hi Diamian,

    I am destroying data table and re-initializing it.

  • DaimianDaimian Posts: 62Questions: 1Answers: 15

    Do not destory the Datatable. Just use the ajax.reload() to refresh the table and if you want to keep sorting and page then use ajax.reload(false).

This discussion has been closed.