Search code examples
javascriptextjsextjs4extjs4.2

Select a tree node does not work


I have an application in Extjs and I need to select a specific node to expand the tree.

I am using the following method:

var record = tree.getRootNode().FindChild('text', 'employee', true); 
tree.getSelectionModel().select(record);

in this way does not work, but if I select any one node and then run the above method, it works without problems.

Help please

UPDATE CODE:

tree.expandPath(route, "text", "->", function() {
             var record = tree.getRootNode().findChild('text','BASE',true);
             tree.getSelectionModel().select(record);
        }); 

Solution

  • Friends thanks for your help, I was able to solve my problem.

    Apparently I did not select the node because it had not shown the window and the nodes were not available, so here add a listener after render.

    so I stay my code:

    listeners: {
        afterrender : function(){
              this.selectPath(this.ruta, 'text', '->', function (s,n) {
                  var nodeEl = Ext.get(this.view.getNode(n));                                     
                  nodeEl.scrollIntoView(this.view.el, false, true);
                  });
        }
    }
    

    this solution apart from selecting me too the node moves to its location in the tree.

    hopefully serve them.

    Greetings!