2013-07-19 102 views
0

我正在研究此ExtJS 4應用程序,我有一部分可以管理應用程序用戶。如何在浮動窗體面板中刷新網格面板的商店?

窗體彈出窗口floating: true

var user_grid_form = Ext.create('Ext.form.Panel', 
{ 
    xtype  : 'form-grid', 
    frame  : true, 
    title  : 'User Information', 
    floating : true, 
    draggable : true, 
    closable : true, 
    closeAction : 'hide', 
    bodyPadding : 5, 
    layout  : 'column', 
    closeAction : 'destroy', 
    width  : 532, 
    items  : 
    [ 
     user_grid, 
     user_textfield 
    ], 
    buttons : 
    [ 
     { 
      text : 'Save Edits', 
      icon : 'images/save.png', 
      handler : handleUpdates 
     }, 
     { 
      text : 'Delete User', 
      icon : 'images/delete.png', 
      handler : handleDeletes 
     } 
    ] 
}).show(); 

user_grid是在我的窗板網格顯示usernames

現在,問題是,當我選擇一個用戶名,就像jhony並按Delete UserhandleDeletes通過Ajax更新數據庫。但後來我嘗試刷新user_grid,它不會工作。 刪除後,用戶應該從user_grid

消失這是我曾嘗試handleDeletes裏面做:

user_store.splice(ind, 1);  // I removed `jhony` from `user_store` 
           // which is the `store` for `user_grid`    
user_grid.getView().refresh(); // Now trying to refresh and NO ERRORS NO ACTIONS 

感謝您的任何線索。

回答

1

其實,你想要做的是:

user_grid.getStore().remove(yourRecord); //remove record from the store and also from the grid view 
user_grid.getStore().sync(); //send changes to the server 
0

而不是

user_grid.getView().refresh(); 

嘗試

user_grid.store.load(); 

,並沒有必要做。如果刪除是進行服務器端店裏別的(拼接)。

0

感謝您的回答dbrin但它沒有奏效。

我認爲沒有必要觸摸user_grid網格面板。我只需要更新它的store。 這個商店有data,一旦我這樣做,一切工作:

user_store.splice(ind, 1); 
u_store.load(user_store); 
// u_store is the store that has user_store data