2014-11-05 41 views
1

在ExtJS5我有一個TreePanel啓用拖放。 當我從源樹中將具有子項的節點拖動到目標樹時,只會複製父節點。ExtJS5樹dragdrop深複製

如果我嘗試在「beforedrop」聽衆深克隆時,出現以下錯誤: Ext.data.Model.constructor():壞模型構造函數的參數2 - 「會話」是不是一個會話

該視圖有一個viewcontroller,但沒有視圖模型。鑑於

樹定義:

xtype: 'treepanel', 
        itemId: 'myProjectsTree', 
        rootVisible: false, 
        viewConfig: { 
         plugins: { 
          ptype: 'treeviewdragdrop', 
          enableDrag: false, 
          enableDrop: true 
         }, 
         listeners: {        
          beforedrop: 'doDrop',.... 

在控制器:

doDrop: function(dropNode, dragNode, overModel) { 
     var node = dragNode.records[0]; 
     var clonedNode = node.copy('111', true);<--- failed here 

我看到的視圖模型方案中定義的會話。 複製函數是否需要定義viewmodel會話? 有沒有辦法解決這個問題。 ExtJS5中是否存在缺陷?

任何幫助,非常感謝!

回答

2

AFAIK EXT JS中存在與複製樹節點相關的錯誤(EXTJS-13725)。 您應該修改/覆蓋copy方法Ext.data.NodeInterface

// copy: function(newId, deep) { 
copy: function(newId, session, deep) { 
    var me = this, 
     result = me.callParent(arguments), 
     len = me.childNodes ? me.childNodes.length : 0, 
     i; 


    if (deep) { 
     for (i = 0; i < len; i++) { 
      // result.appendChild(me.childNodes[i].copy(undefined, true)); 
      result.appendChild(me.childNodes[i].copy(undefined, session, true)); 
     } 
    } 
    return result; 
} 

基本上處於原來的代碼沒有會話參數,而應該有。

1

或者設置copy:true

viewConfig: { 
     plugins: { 
      ptype: 'gridviewdragdrop', 
      enableDrag: true, 
      enableDrop: false, 
      ddGroup: 'selDD', 
      copy: true 
     },