您好,欢迎访问一九零五行业门户网

GRID拖拽行的实例代码_javascript技巧

---------------------grid拖拽行的实例代码  单行拖拽---------------------------------------
复制代码 代码如下:
//创建第一个grid
var firstgrid = new ext.grid.gridpanel({
ddgroup : 'secondgridddgroup',//这里是第二个grid的ddgroup
store       : firstgridstore,
enabledragdrop : true,//true表示启动对于gridpanel中选中行的拖动行为
……其他属性省略
});//创建第二个grid
var secondgrid = new ext.grid.gridpanel({
ddgroup : 'firstgridddgroup',//这里是第一个grid的ddgroup
store       : secondgridstore,
enabledragdrop : true,//true表示启动对于gridpanel中选中行的拖动行为
……其他属性省略
});
//创建第一个grid的ddgroup
var firstgriddroptargetel = firstgrid.getview().el.dom.childnodes[0].childnodes[1];
var firstgriddroptarget = new ext.dd.droptarget(firstgriddroptargetel, {
ddgroup    : 'firstgridddgroup',//和第二个grid的ddgroup相同
copy        : true,
notifydrop : function(ddsource, e, data){
   function addrow(record, index, allitems) {
    var founditem = secondgridstore.find('name', record.data.name);
    if (founditem == -1) {
     firstgridstore.add(record);
     firstgridstore.sort('name', 'asc');
     ddsource.grid.store.remove(record);
    }
   }
   ext.each(ddsource.dragdata.selections ,addrow);
   return(true);
}
)};
//创建第二个grid的ddgroup
var secondgriddroptargetel = secondgrid.getview().el.dom.childnodes[0].childnodes[1];
var secondgriddroptarget = new ext.dd.droptarget(secondgriddroptargetel,{
ddgroup : 'secondgridddgroup',//和第一个grid的ddgroup相同
copy        : true,
notifydrop : function(ddsource, e, data){
   function addrow(record, index, allitems) {
    var founditem = secondgridstore.find('name', record.data.name);
    if (founditem == -1) {
     secondgridstore.add(record);
     secondgridstore.sort('name', 'asc');
     ddsource.grid.store.remove(record);
    }
   }
   ext.each(ddsource.dragdata.selections ,addrow);
   return(true);
}
});
其它类似信息

推荐信息