Restore table state on demand
Restore table state on demand
xtech_dev
Posts: 25Questions: 11Answers: 0
Hello,
Is there a way to restore table state on demand?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @xtech_dev ,
If you use
stateSave
, this will return the table to it's previous state.Cheers,
Colin
but i have other scenario:
- page loaded
- table is loaded with data (state is restored)
- data edit (post to server)
- table reload with current data form server
- and here i would like to have state restore (without table reinitialization and without page refresh)
-
Hi @xtech_dev ,
Yep, that fourth point, the table reload, that would just require an
ajax.reload()
- the table retains it's state, it just gets a data refresh.Cheers,
Colin
i'm not using build in ajax data loading. i have custom loader - will it work when i call ajax.reload() when data source parameters are not specified?
ajax.reload()
uses theajax
config. Since you don't have that it won't do anything for you.Maybe for point number 4 you could use the following:
-
page()
to get the current page-
clear()
to clear the table data-
rows.add()
to add the current data-
draw()
to redraw the table-
page()
to jump to the saved page in step 1Kevin
Thanks very much your help!
My solution goes like this:
As soon as form is successfully submitted i'm restoring page with this extension method:
so on demand i use:
mytablereference.restorePage(appContext.tableState)
Actually having state object saved i can restore even more settings like sorting and filters.
It Man