2014-05-03 53 views
0

我在ExtJs(Tree-1和Tree-2)中开发了两个树面板。在所有情况下,这些树木正在拖拽两个树木之间。我只想在以下情况下拖放 (从树-1到树-2),(从树-1到树-1)和(从树-2到树-2)。这是要限制从树-2到树-1的拖放。以下是我的源代码。限制在ExtJs树面板中的拖放

/*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' 
       }] 
      }), 

这些代码可以在拖放时进行剪切和粘贴。我想将这些代码作为复制和粘贴,同时拖放。请帮帮我。 在此先感谢。

+1

任何人都可以帮助我,请。我在等。 –

回答

2

看看这个例子中从文档:

http://docs.sencha.com/extjs/4.2.2/extjs-build/examples/tree/custom-drop-logic.html

基本上它使用nodedragover事件来控制,当一个可以丢弃或没有。

当您不想允许放置时返回false。

至于使它复制,而不是切割时,文档中提到以下(虽然我从来没有尝试过自己):

此插件提供阻力和/或一个TreeView拖放功能。

它创建DragZone的专用实例,它知道如何拖动 出一个TreeView和加载被传递到 具有以下性质的合作DragZone的方法将数据对象:

副本:布尔

TreeView的副本属性的值,或真如果TreeView的是 与allowCopy配置:真当 拖拽操作开始按下控制键。

尝试将设置copy: true设置为两个视图。