How to show selected state on page load in a tree with checkbox?

I want to show the selected state in checkbox on page load,my code is like this:
$(document).ready(function(){
var tree = new dhx.Tree(“tree”,{checkbox:true});
tree .data.load("/role/searchTree.do");
var state=JSON.parse(’${state!}’);
tree.setState(state);
});
I found the setState method was not take effect,but will work good on button click,so how can i set tree state on my page load?

I’ve found the method,use .then() after .load()

1 Like