Extjs Drag and;掉落在两个网格之间

时间:2011-07-07 10:50:37

标签: extjs

我需要从grlRicProd拖放到grlInsOrd

grlIRicProd: .....

id: 'grlRicProd', 
sm: new Ext.grid.RowSelectionModel({ 
    singleSelect: false 
}), 
enableDragDrop: true, ddGroup: 'grlRicProd-dd',
ddText: 'Prodotto Selezionato',

...

grlInsOrd
....

id: 'grlInsOrd', 
enableDragDrop: 
true, ddGroup: 'grlInsOrd-dd', 
listeners: { 
"render": { 
 fn: function(grid) { 
   var ddrow = new Ext.dd.DropTarget(Ext.getCmp('grlInsOrd').getEl(), { 
   ddGroup: 'grlRicProd-dd', // Data come from?? 
   copy: false, 
   notifyDrop: function(dd, e, data) { 
     var sm = Ext.getCmp('grlRicProd').getSelectionModel(); 
     var rows = sm.getSelections(); 
     var cindex = dd.getDragData(e).rowIndex; //cindex IS UNDEFINED! WHY? 
     if (sm.hasSelection()) {
        for (i = 0; i < rows.length; i++) {
            Ext.getCmp('grlRicProd').store.remove(Ext.getCmp('grlRicProd').store.getById(rows[i].id)); //THIS WORKS FINE 
           Ext.getCmp('grlInsOrd').insert(cindex,rows[i]);//ERROR cindex is not defined
        } 
        sm.selectRecords(rows);
      }
  }); 
} 

} }

我该怎样解决? 谢谢!

1 个答案:

答案 0 :(得分:2)

请参阅此示例及其代码:

http://dev.sencha.com/deploy/ext-4.0.2a/examples/dd/dnd_grid_to_grid.html

完美无缺!你正在做一些不需要的事情。复制,创建和删除都是自动完成的。