简体   繁体   中英

dijit.Tree set path and scroll to selected node

Actually I'm stuck. I'm trying to select node in dojo tree and immediately scroll to it. But I don't understand how to implement this.

next code:

this.set("path", ["root", "folder", "file"]);
this.focusNode(this.selectedNode.id);

isn't working

this one:

this.set("path", ["root", "folder", "file"]);
win.scrollIntoView(this.selectedNode.id);

works! but only if folder (parent leaf) of tree is already opened. And it isn't working if parent folder is closed.

So... Could somebody help me?

PS Here is very easy example: http://jsfiddle.net/hjnx9/6/

I click on the button and would like to select some node in the tree and scroll to it. At first time node just will be selected (but scrolling isn't working). At second time node will be selected again and scrolling going to work this time. How to fix it???

PSS I think that problem is that set("path",...) opens the folder of tree not immediately (animation takes about 200 ms). So may be I need some kind of callback?

set("paths", ...) returns a Promise, so, your problem can be solved in the following way:

    //select node
    _Tree.set("path", ["root", "folder49", "file25_folder49"]).then(
      function(path) {
        // executes when set("path", ..) is complete
        var item = _Tree.model.store.data[2526];
        _Tree.onClick(item);        
      }
    );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM