带checkbox的treepanel实例

带checkbox的treepanel实例
下面的代码定义了一个完整的ext treepanel的实例,其中,对checkchange事件的处理,使单击父亲节点时对下面的子节点全部选中或取消选中。

sysFunClassTree  =   new  Ext.tree.TreePanel({
    id:'sysFunClassTree',split:
true ,collapsible: true ,rootVisible: false ,name:'sysFunClassTree',autoScroll: true ,border: true ,
    region:'east',title:'功能分类树',width:
200 ,
    loader:
new  Ext.tree.TreeLoader({dataUrl:'http: // localhost:8080/jeasyweb/treeSysFunClass.do',baseParams:{'_tree_checkbox':'true'}})
});
sysFunClassTree_root 
=   new  Ext.tree.AsyncTreeNode({
    text:'Ext TreeRoot',id:'src_root' 
});
sysFunClassTree.setRootNode(sysFunClassTree_root);
sysFunClassTree.on('click', 
function (node, e){treeClick(node, e);});
sysFunClassTree.on('checkchange', 
function (node, flag) {
    
if  (node.hasChildNodes()) {  
        node.eachChild(
function (child) {  
            child.ui.toggleCheck(flag);  
            child.attributes.checked 
=  flag;  
            child.fireEvent('checkchange', child, flag);
        });  
    }  
});

你可能感兴趣的:(带checkbox的treepanel实例)