在extjs网格中拖放的行的顺序

时间:2012-07-03 11:27:22

标签: extjs drag-and-drop grid

我在这样的网格中使用拖放功能:

{
xtype: 'gridpanel',
id: 'editlinesGrid',
title: 'line',
forceFit: true,
store: 'gridEditlines',
region: 'center',
viewConfig: {
    plugins: [
    Ext.create('Ext.grid.plugin.DragDrop', {
        ptype: 'gridviewdragdrop'
    })],
    listeners: {
        drop: {
            fn: me.onGriddragdroppluginDrop,
            scope: me
        }
    }
},
columns: [{
    xtype: 'rownumberer',
    dataIndex: 'stopOrder'
}, {
    xtype: 'gridcolumn',
    dataIndex: 'stopId',
    text: 'stopId',
    field: {
        xtype: 'combobox',
        allowBlank: false,
        displayField: 'stopId',
        store: 'gridStops'
    }
},

当我将行拖到更高或更低的位置时,我需要将新位置发送到服务。我需要发送的是:

{
"stopOrder": 1,  <-- here should be the new position in the grid
"stopDTO": {
"stopId" : 1
}
}

这是我用于拖放的事件绑定

 onGriddragdroppluginDrop: function(node, data, overModel, dropPosition, options) {
    alert(data);
},

将数据发送回服务需要做什么?

1 个答案:

答案 0 :(得分:6)

如果问题没有得到解答,而且我也花了一些时间来“找到”它,这是指向主要文件Reorder grid rows using DnD的链接