2015-04-28 42 views
1

ExtJs中有一個完整的liveSearchGridPanel。編輯任何行時發生錯誤。發生的事情是,如果更新的行必須像我的情況那樣在我改變用戶的年齡(我根據年齡進行排序)時使用,但行在網格中上升或下降,但之前的記錄也保持在那裏直到我手動刷新整個網頁。截圖低於Extjs中行編輯插件的問題

Screen Shot of My web page after editing

我的代理模式是:

fields: [ {name: 'id', type: 'int', persist: false}, 
       {name: 'gender', type: 'auto'}, 
       {name: 'name', type: 'auto'}, 
       {name: 'age', type: 'int'}], 


    identifier: 'sequential', // to generate -1, -2 etc on the client 
    proxy: { 
     type: 'rest', 
     //format: 'json', 
     //appendId: false, 
     idParam: "id", 
     //limitParam:"", 
     //filterParam: "", 
     //startParam:'', 
     //pageParam:'', 
     url:'http://localhost:3000/posts', 
     api: 
     { 
      read : 'http://localhost:3000/db', 
      create: 'http://localhost:3000/posts', 
      update : 'http://localhost:3000/posts' , 
      destroy : 'http://localhost:3000/posts' 

     }, 

     headers: {'Content-Type': "application/json" },  

     reader: { 
     type: 'json', 
     rootProperty:'posts', 

     totalProperty: 'total' 

     }, 
     writer: { 
      type: 'json' 
     } 

在application.js中,我已經定義行編輯插件爲:

var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', { 
     listeners: { 
      cancelEdit: function(rowEditing, context) { 
       // Canceling editing of a locally added, unsaved record: remove it 
       if (context.record.phantom) { 
        store.remove(context.record); 
       } 
      }, 

      edit: function(editor, e) { 
       // commit the changes right after editing finished 
       e.record.commit(); 
       } 
     } 
    }); 

我的店是這樣的:

storeId: 'peopleStore', 
     pageSize: 500, 

     //buffered: true, 
     //leadingBufferZone: 300, 

     pageSize: 5, 

     autoLoad: {start: 0, limit: 5}, 
     autoSync: true, 

     sorters: [{ 
      property : 'age', 
      direction:'ASC' 
     }], 

     groupField: 'gender' 

任何人都可以指出我的錯誤嗎?我試圖在rowEditing的'編輯'功能編輯後重新加載我的商店,但它沒有奏效。

謝謝你的時間。

+1

你試過'Ext.data.StoreManager.lookup('peopleStore')。reload()'? – Tyr

+0

@Tyr謝謝,這工作。請你把它作爲答案,以便我可以接受它,並且這個線程會讓我爲將來的用戶回答問題。 –

回答

3

如要求完整的答案:

你試過Ext.data.StoreManager.lookup('peopleStore').reload()

+0

非常感謝。 –