ext check tree

 

 来源: http://2008shucheng.iteye.com/blog/645260

 

var Tree = Ext.tree;          
    var tree = new Tree.TreePanel({          
        el:'tree-div',          
        useArrows:true,          
        autoScroll:true,          
        animate:true,          
        enableDD:true,          
        containerScroll: true,           
        loader: new Tree.TreeLoader({          
        dataUrl:'treecheckjson.jsp'         
        })          
    });          
     
     tree.on('checkchange', function(node, checked) {             
        node.expand();             
        node.attributes.checked = checked;             
        node.eachChild(function(child) {             
            child.ui.toggleCheck(checked);             
            child.attributes.checked = checked;             
            child.fireEvent('checkchange', child, checked);             
        });             
    }, tree);          
          
    var root = new Tree.AsyncTreeNode({          
        text: 'Ext JS',          
        draggable:false,       
        checked:false,      
        id:'0'         
    });          
    tree.setRootNode(root);         
          
    tree.render();          
    root.expand();        
 //带复选框(checkbox)的树         
//改编自ExtJs 自带的tree例子,选中父节点后,所有子节点会自动选上。      
//该例子点击父节点如果速度过快,有时候不会自动选中子节点!     
var checkedNodes = tree.getChecked();//tree必须事先创建好.      
var s = [];      
for(var i=0;i<checkedNodes.length;i++){      
s.push(checkedNodes[i].id)      
}   //得到里面选中的node id 值数组  

 

你可能感兴趣的:(check)