2

EditorGridPanel 内で行を移動する実際の例を知っている/知っている人はいますか (または、それが機能しない理由を知っています)。私はいくつかの例を見つけましたが、私が見つけたものはこのアプローチを使用しています:

// calculate the new index, then remove the record from the store, and re-insert it at the new index
grid.getStore().remove(record);
grid.getStore().insert(index, record);

私の場合、これは失敗します。グリッドでは問題ないように見えますが、実際には 2 つの DELETE http 要求がサーバーに送信され、PUT は送信されません。これは、ページをリロードすると明らかになります。移動した行は実際には削除されています。

彼は私の店の基本的な設定です:

var remoteJsonStore = new Ext.data.JsonStore({
            storeId: 'colStore',
            autoDestroy: false,
            autoSave: true,
            proxy: new Ext.data.HttpProxy({url:'/exercises/collect/data_rows'}),
            restful: true,
            format: 'json',
            disableCaching: false,
            autoLoad: true,
            writer: new Ext.data.JsonWriter({
              encode: false
            }),
            root: 'data',
            idProperty: 'data_row_id',
            fields: recordFields,
            baseParams:{section_id:GridUtils.properties[gridId]['section_id']},
            listeners:{
              exception:function(misc){
                 // stuff....
              },
              beforewrite:function(store, action, rs, options, arg){
                this.baseParams["position"]=rs.rowIndex;
              },
              beforesave:function(store, data){
                 // stuff....                }
              }
            }
});
4

1 に答える 1

6

DnD 並べ替えビューを実装するときにも同様の問題がありました。問題は、再挿入した場合でも、ストアがすべての remove()d レコードに削除のマークを付けることです。

Ext.data.Store の remove() メソッドのソースを読んで、解決策を見つけました。

remove: function(records, /* private */ isMove) {

見る?2 番目のブール引数を渡して、レコードを移動しているだけであることをストアに伝えることができます。ただし、非公開としてマークされ、文書化されていないため、フレームワークの新しいバージョンにアップグレードするときは注意が必要です。

したがって、最終的な解決策は次のとおりです。

grid.getStore().remove(record, true); // just moving
grid.getStore().insert(index, record);

ExtJS バージョン: 4.1

于 2012-09-12T20:16:29.570 に答える