zoukankan      html  css  js  c++  java
  • EXTJS4 如何默认选中树(treeview)的节点

       var record = treePanel.getStore().getNodeById('item_id');
       treePanel.getSelectionModel().select(record)

    完整的示例如下:
    var store = Ext.create('Ext.data.TreeStore', {
        root: {
            expanded: true,
            children: [
                { text: "detention", leaf: true },
                { text: "homework", expanded: true, children: [
                    { text: "book report", leaf: true },
                    { text: "alegrbra", id:'select', leaf: true}
                ] },
                { text: "buy lottery tickets", leaf: true }
            ]
        }
    });
    
    Ext.create('Ext.tree.Panel', {
        title: 'Simple Tree',
         200,
        height: 150,
        store: store,
        rootVisible: false,
        renderTo: Ext.getBody(),
        listeners:{
            afterrender:function(){
              var record = this.getStore().getNodeById('select');
                this.getSelectionModel().select(record)
            }
        }
    });

    运行效果如图:树产生后,默认选中了ID='select'的这一项 

  • 相关阅读:
    创建HttpFilter与理解多个Filter代码的执行顺序
    Filter
    JSTL
    EL
    JavaBean
    HttpSession之表单的重复提交 & 验证码
    相对路径和绝对路径
    HttpSession之简易购物车
    HttpSession
    Cookie
  • 原文地址:https://www.cnblogs.com/zdkjob/p/3045059.html
Copyright © 2011-2022 走看看