我在ExtJ中开发了两个树面板(Tree-1和Tree-2)。在所有情况下,这些树都在两棵树之间拖放。我希望在以下情况下拖放(从树-1到树-2),(从树-1到树-1)和(从树-2到树-2)只。这是想限制拖放从树-2到树-1。以下是我的源代码。
/*Tree1*/
Ext.create('Ext.tree.Panel', {
title: 'From Agent:',
collapsible: true,
collapseDirection: Ext.Component.DIRECTION_TOP,
frame:true,
width: 310,
minHeight: 50,
margin: '0 0 0 0',
store: store1,
listeners:{
checkchange:function( node, checked, eOpts){
node.cascadeBy(function(n){n.set('checked', checked);} );
}
},
rootVisible: false,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
sortOnDrop: true,
containerScroll: true
}
},
sorters: [{
property: 'text',
direction: 'ASC'
}]
}),
/*Tree2*/
Ext.create('Ext.tree.Panel', {
title: 'To Agent:',
frame: true,
collapsible: true,
collapseDirection: Ext.Component.DIRECTION_TOP,
width: 310,
margin: '0 0 0 20',
minHeight: 50,
store: store2,
listeners:{
checkchange:function( node, checked, eOpts){
node.cascadeBy(function(n){n.set('checked', checked);} );
}
},
rootVisible: false,
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
sortOnDrop: true,
containerScroll: true
}
},
sorters: [{
property: 'text',
direction: 'ASC'
}]
}),这些代码在拖放时以剪切和粘贴的方式工作。我想让这些代码复制和粘贴,同时拖放。求你帮帮我。提前谢谢。
发布于 2014-06-15 13:27:30
从docs中查看这个示例:
http://docs.sencha.com/extjs/4.2.2/extjs-build/examples/tree/custom-drop-logic.html
基本上,它使用nodedragover事件来控制何时可以删除或不删除。
当您不想允许下降时,返回false。
至于复制而不是裁剪,文档中提到了以下内容(尽管我自己从未尝试过):
这个插件为TreeView提供了拖放功能。 它创建一个专门的DragZone实例,该实例知道如何从TreeView中拖出并加载数据对象,该数据对象传递给协作DragZone的方法,具有以下属性: 复制:布尔 TreeView的copy属性的值,如果TreeView配置了allowCopy: true,则为true,并在拖动操作开始时按下控制键。
尝试将copy: true设置为两个视图。
https://stackoverflow.com/questions/23442514
复制相似问题