Save and restore treetable state

I use this documentation for save and restore treetable state:

In my situation it doesn't work , maybe because I reload treetable from server ?

1) I load treetable from server (nodes closed)

2) I open parent nodes buy clicks

3) I save the treetable state

4) I reload treetable from server (node closed)

5) I restore treetable last state

When I look in firebug, the treetable data saved with open nodes in local storage are ok but the nodes are always closed in view


  • Hello @romain ,
    To restore the state, use ready handler or call the setState after component initialization:

        var state ="requirements_content_treetable_state");
        if (state)

    Please check the next snippet:

  • edited November 2020

    Thanks , but it doesn't work for me where data are reload from server.

    I have a function that reload my tree when I make a modification.

    The server doesn't know what nodes had opened in front.

    This function save the state, clear the tree and reload data from server.

    I tried to set the state saved (data saved are ok in local storage) with event "onAfterLoad" , but it doesn't work too, the nodes are always closed even if the state saved has : open: Array(3) [ "1", "2", "3" ]

    function treeListsReload() {
                var state = $$("listsTreeTable").getState();
      "list_state", state);
                utils.loadBListsTreeFromDb($$("listsTreeTable")); //clear treetable and reload from server
                        "onAfterLoad", function () {
                            var state ="list_state");
                            if (state){

    Any ideas ?

  • Hi @romain,
    Unfortunately, I wasn't able to reproduce this issue under the described scenario, e.g.: If at all possible, could you please providean isolated example where the issue can be seen?

  • It is ok :) After a lot of tests , I understood why for me it didn't work , it wasn't simple because my view contains a lot of interactions (6000 lines of code ..), I have a event "onAfterFilter" and in this event I used the method "closeAll" for nodes and when tree is reload , the event is triggered .. Thanks for example ;)

  • Hello , is it possible to restore just some properties for datatable ?

    For example I don't want to restore "filter" object of my datatable.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!