Ext treeplane 拖动 选择 enableDD enableDrag
by SaveLearn on 二.23, 2010, under EXT
Ext 的拖动效果是非常好的,但是用原始的例子做了个实验,拖动加选择弹页的时候会出现一个为空的报错,然后修改了一下,现在已经好了,大家多多支持啊
var sysctrlb = new Ext.tree.TreePanel({
id : ‘west-panel2′,
region : ‘west’,
title : ‘文章管理’,
iconCls : ‘book’,
split : true,
width : 200,
minSize : 175,
maxSize : 400,
collapsible : true,
margins : ’0 0 5 5′,
enableDrag:true,
enableDD :true,
rootVisible : false,
lines : false,
autoScroll : true,
root : new Ext.tree.AsyncTreeNode({
text : ‘Manage’,
expanded : true,
children : [{
text : '新建用户',
leaf : true
}, {
text : '用户列表',
leaf : true
}, {
text : '用户组',
leaf : true
}]
})
});
上面是树的建立方法,然后是 监听选择方法,
var sm = sysctrlb.getSelectionModel();
var cp = Ext.getCmp(‘center-panel’);
sm.on(‘selectionchange’, function(sm, node) {
if (node!=null) {
if (node.isLeaf()) {
//alert(node.href);
var tab = cp.getItem(node.id);
if (tab == null) {
tab = new Ext.Panel({
id : ” + node.id,
title : node.text,
iconCls : ‘appIcon’,
html : “<iframe src=’Manage/”+node.id+”‘ width=’100%’ height=’100%’/>”,
closable : true,
autoScroll : true
});
cp.add(tab);
}
cp.setActiveTab(tab);
node.suspendEvents(true);
}
}
});