Saving state in local storage

Hi,
I am getting the state but its not working(not setting the state).

 webix.attachEvent('unload', function(){
         webix.storage.local.put("state", $$("testTree").getState());
     }); 

 var state = webix.storage.local.get("state");
            if (state){
            	 $$("testTree").setState(state);

This is my code. But not working.
Thanks

Hello,

As far as I can see, the code works well. Please, follow the snippet and open/close or select nodes and refresh the page: https://webix.com/snippet/af677bb5

You can also watch the logged state in the browser console.

Hi,
Thanks for reply. I am using same code but its not working. I am using onItemClick event to open tree node and angular for routing so is affecting functionality of local storage?

app.controller("TreeController", ['$scope', '$http', '$rootScope', '$timeout', function($scope, $http, $rootScope, $timeout) {
	$rootScope.treeData=[];
	var tree =$scope.tree_config = {
        id: "testTree",
        view: "tree",
        select: true,
        template: "{common.icon()}<span><a id='treetag' ui-sref='#link#' href='##link#' ui-sref-active='active' style='text-decoration: none;'>{common.folder()}#value#</a></span>",
        data: [{
            id: 'root',
            value: 'fams',
            webix_kids: true,
            link: 'fams',
            open: true
        }],
        ready: function() {
            this.select("root", true);         
            var state = webix.storage.local.get("state");
            if (state){
              	console.log("get", state)
            	$$("testTree").setState(state);      
            }
            
        },
        on: {
            onDataRequest: function(id, callback, url) {
                this.parse(
                    webix.ajax().post("loadTree?parent=" + id + "&sessionKey=" + sessionKey + "&treeName=TestOrderProjectTree&moduleName=Test Order Management&node=" + id).then(function(data) {
                    	//console.log(data.json())
                    	return data = data.json();
                    })
                );
                this.getItem(id).$count = 0;
                return false;
            },
            onItemClick: function(id, e, node) {
            	$$('testTree').adjust();
                selectedProjectId = this.getItem(id).uid;
                var nodeType = this.getItem(id).nodeType;
                switch (nodeType) {
                    case 'Project':
                        {
                            $timeout(function() {
                                $rootScope.$broadcast("CallProjectDetailsMethod", selectedProjectId);
                            }, 200);
                            break;
                        }
                    case 'SubProject':
                        {
                            $timeout(function() {
                                $rootScope.$broadcast("CallSubProjectDetailsMethod", selectedProjectId);
                            }, 200);
                            break;
                        }
                }
            }
        },
    };
    webix.attachEvent('unload', function(){ 
    	  console.log("put", $$("testTree").getState())
    	  webix.storage.local.put("state", $$("testTree").getState());
	});  
   }]);

this is my code. But its not working here.

Hi Helga,
Please reply me I am stuck.

Please, check the snippet based on your code, it still works for me: https://webix.com/snippet/9ea582bb

Could you please change this snipet so that the issue can be spotted? In which way doesn’t it work for you?