1

My Rally カスタム データ ストアが更新されません。[this][1] の投稿で説明されている問題が発生しています。

私のシナリオは次のとおりです。カスタム データ ストアを持つグリッドに行を追加します。次に、グリッド列を並べ替えると、追加した新しい行がすべて削除されます。私のカスタム ストアには特別なことはありません。autoSync:true を試してみましたが、何も起こりません。

元のデータに加えられた変更は一時的なものであり、reload() で削除されるという意味で、カスタム ストアは読み取り専用ですか?

これは私がラリーグリッドに追加する私の店です

        me.customStore = Ext.create('Rally.data.custom.Store', { 
            data: customData,
            listeners:{
                load: function(customStore){
                    //do some stuff
                }
            }
        });
4

1 に答える 1

1

Rally.data.custom.Storeメモリ プロキシのソース コードを調べたところ、ストアで何も追加、削除、または正しく更新されなかった理由がわかりました。メモリ プロキシの create メソッドと destroy メソッドをオーバーライドする必要があります。

現在のメモリのプロキシ機能

これらは、メモリ プロキシのレコードを作成および破棄するために使用される関数です。ご覧のとおり、レコードを作成または破棄しません...

updateOperation: function(operation, callback, scope) {
    var i = 0,
        recs = operation.getRecords(),
        len = recs.length;

    for (i; i < len; i++) {
        recs[i].commit();
    }
    operation.setCompleted();
    operation.setSuccessful();

    Ext.callback(callback, scope || this, [operation]);
},    

create: function() {
    this.updateOperation.apply(this, arguments);
},

destroy: function() {
    this.updateOperation.apply(this, arguments);
},

正しいメモリ プロキシ設定

以下は、カスタム ストア内のレコードを実際に追加および削除するカスタム ストアをインスタンス化する方法です。

    me.customStore = Ext.create('Rally.data.custom.Store', {
        data: //customData
        model: //modelType
        autoSync:true,
        proxy: {
            type:'memory',
            create: function(operation) {
                var me = this;
                operation.getRecords().forEach(function(record){
                    console.log('adding record', record);
                    me.data.push(record);
                });
                this.updateOperation.apply(this, arguments);
            },
            destroy: function(operation) {
                var me = this;
                operation.getRecords().forEach(function(record){
                    console.log(record);
                    for(var i = 0;i<me.data.length;++i){
                        if(/*me.data[i] == record*/ ){
                            me.data.splice(i, 1);
                            return;
                        }
                    }
                });
                this.updateOperation.apply(this, arguments);
            }
        },
        listeners://listener stuff here
    });
于 2014-07-24T19:41:51.917 に答える