http://chenjumin.iteye.com/blog/671752
/*!
* Ext JS Library 3.2.1
* Copyright(c) 2006-2010 Ext JS, Inc.
*
[email protected]
* http://www.extjs.com/license
*/
Ext.onReady(function(){
var tree = new Ext.ux.tree.ColumnTree({
width: 850,
height: 500,
enableDD:true,
rootVisible:true,
autoScroll:true,
checkModel:'cascade',//级联多选,如果不需要checkbox,该属性去掉
onlyLeafCheckable: false,//所有结点可选,如果不需要checkbox,该属性去掉
title: 'Example Tasks',
renderTo: Ext.getBody(),
listeners: {
'checkchange': function(node, checked){
if(checked){
node.getUI().addClass('complete');
}else{
node.getUI().removeClass('complete');
}
}
},
buttons: [{
text: 'Get Completed Tasks',
handler: function(){
var msg = '', selNodes = tree.getSelectionModel().getSelectedNode();
selNodes = tree.getChecked();
Ext.each(selNodes, function(node){
if(msg.length > 0){
msg += ', ';
}
msg += node.attributes.id;
//alert(msg);
});
Ext.Msg.show({
title: 'Completed Tasks',
msg: msg.length > 0 ? msg : 'None',
icon: Ext.Msg.INFO,
minWidth: 200,
buttons: Ext.Msg.OK
});
}
}],
columns:[{
header:'Task',
width:330,
dataIndex:'task'
},{
header:'Duration',
width:200,
dataIndex:'duration'
},{
header:'Assigned To',
width:300,
dataIndex:'user'
}],
loader: new Ext.tree.TreeLoader({
// dataUrl:'column-data.json',
uiProviders:{
'col':Ext.ux.ColumnTreeCheckNodeUI
}
}),
root: new Ext.tree.AsyncTreeNode({
text:'Tasks'
})
});
tree.on('beforeload',
function(node){
// tree.loader.dataUrl='column-data.json';
alert("123");//定义子节点的Loader
});
});