dijit.Tree set paths JsonRestStore + ForestStoreModel

819 Views Asked by At

I have a JsonRestStore + ForestStoreModel Tree and it's working fine but when I try to access a node directly with the tree.set('paths', ...) function it doesn't work.

Please refer to this little example here: http://wasmonitor.com/dojotree.html

If you click on the button, it should expand Web Servers and select web1 but it doesn't... This is my issue.

My tree is rootless and I know ForestStoreModel have a default rootId of $root$ when none is specified. So I'm trying to access the node using this code:

    var stree = dijit.byId("statTree");
    stree.set("paths",  [ "$root$", "WebServers", "web1" ]);

But it never opens.

Already read this question: diji.Tree + JsonRestStore - selecting node programmatically with tree.set("path" that is similar but it's not working for me...

Any hints ?

Thanks !

Richard

1

There are 1 best solutions below

0
On

Found out that path and paths settings were totally different. path accept a single path as an array and paths accepts an array of arrays. Also, I was relying on $root$ as the default rootId but to make it work I had to spefify a rootId in the ForestStoreModel declaration. After that, the correct syntax would be:

    var stree = dijit.byId("statTree");
    stree.set("path",  [ "statTree", "WebServers", "web1" ]);

or

    var stree = dijit.byId("statTree");
    stree.set("paths",  [[ "statTree", "WebServers", "web1" ]]);

Thanks to Sam for pointing that to me by email !