使用xtype treecolumn不会选择树的第一个节点

时间:2013-04-02 11:33:59

标签: ext4

我通过将xtype指定为treecolumn来创建树面板。我想选择树的第一片叶子。在这个例子中,我已经注册了下面详述的boxready事件:

boxready : function( treePanel, width, height, eOpts ){

    treePanel.getSelectionModel().select( 0 );
    //treePanel.select( treePanel.getRootNode().getChildAt(0) );
    treePanel.getSelectionModel().selected = 0;
},
treePanel.getSelectionModel()

这个例子给了我SINGLE类型的selectionmodel。谁能解释为什么我的例子没有选择第一片叶子?

1 个答案:

答案 0 :(得分:0)

这是一个小“图”:

如果您需要从以下开始的叶子:

  • 选择了一个节点:

    var nodeData = treePanel.getSelectionModel()。getSelection();

  • 从开头:

    var node = treePanel.getRootNode(); - 父亲(第一个节点);

    findLeaf:function(node) {

    if(node.isLeaf()){
    // this is the node that u want
    }else{
        // bucle to find it
        node.eachChild(function(nodeChild,array){
            if(nodeChild.isLeaf()){
               // this is the node that u want
            }else{
               // get childs of this node
               if(nodeChild.hasChildNodes()){
                    //find the childs from this node.
                    this.findLeaf(nodeChild);
               }
            }
        });
    }
    

    };