extjs gridpanel拖放功能

时间:2011-03-23 12:41:01

标签: extjs gridpanel

Ext.namespace('Moca');
.....

Moca.LaGrid = new Ext.grid.GridPanel({
store : Moca.Stores.LaStore,
ddGroup: 'GridDD',
enableDragDrop: true,
.....


  var ddrow = new Ext.dd.DropTarget(Moca.LaGrid.getView().mainBody, {
            ddGroup : 'GridDD',
            copy:false,
            notifyDrop : function(dd, e, data){
                var sm=Moca.LaGrid.getSelectionModel();
                var rows=sm.getSelections();
                var ds = Moca.LaGrid.store;
                var cindex=dd.getDragData(e).rowIndex;
                for (i = 0; i < rows.length; i++) {
                    rowData=c.getById(rows[i].id);
                    if(!this.copy) {
                        ds.remove(ds.getById(rows[i].id));
                        ds.insert(cindex,rowData);
                    }
                };
            }
        });  

它给this.el是null ext-all.js(line7)

请帮助?

1 个答案:

答案 0 :(得分:1)

首先猜测Moca.LaGrid在创建ddrow时尚未渲染到其容器,因此Moca.LaGrid.getView()。mainBody将为null。将GridPanel附加到其容器后尝试创建ddrow。