2014-07-24 31 views
1

我的拉力賽自定義數據存儲不會更新。我遇到了[this] [1]文章中描述的問題。拉力賽自定義數據存儲不會更新

我的方案是:我將行添加到具有自定義數據存儲的網格。然後我排序一個網格列,並且我添加的所有新行都被刪除。關於我的自定義商店沒有什麼特別,我嘗試過autoSync:true,但是它什麼都不做。

自定義存儲區是隻讀的,因爲對原始數據所做的任何更改都是暫時的,並且會使用reload()進行刪除?

這是我的店,我添加到rallygrid

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

回答

1

我看着爲內存代理的源代碼,它使爲什麼越來越添加或移除或與Rally.data.custom.Store商店正確更新沒什麼感覺。您必須重寫內存代理的創建和銷燬方法。

當前內存代理功能

這些是用於創建和銷燬的內存代理記錄功能。正如你所看到的,他們不創造或摧毀任何記錄......

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 
    }); 
相關問題