2013-03-09 93 views
3

我有一個帶有工具欄按鈕的ExtJS網格來保存日期。保存工作和數據被存儲。但網格不刷新。保存後如何重新加載網格數據?Sencha ExtJs保存後存儲的網格刷新

Ext.define('MyLodge.view.content.MemberGrid', { 
extend: 'Ext.grid.Panel', 
alias: 'widget.membergrid', 



initComponent: function(){ 

    var rowEditing = Ext.create('Ext.grid.plugin.RowEditing'); 

    var store = Ext.create('MyLodge.store.Members'); 

    Ext.apply(this, { 
     height: this.height, 
     plugins: [rowEditing], 
     store: store, 
     stripeRows: true, 
     columnLines: true, 
     columns: [{ 
      id  :'id', 
      text: 'ID', 
      width: 40, 
      sortable: true, 
      dataIndex: 'id' 
     },{ 
      text : 'Name', 
      flex: 1, 
      sortable : true, 
      dataIndex: 'name', 
      field: { 
       xtype: 'textfield' 
      } 
     },{ 
      text : 'E-Mail', 
      width : 150, 
      sortable : true, 
      dataIndex: 'email', 
      field: { 
       xtype: 'textfield' 
      } 
     },{ 
      text : 'Href', 
      width : 200, 
      sortable : true, 
      dataIndex: 'href', 
      field: { 
       xtype: 'textfield' 
      } 
     }], 
     dockedItems: [{ 
      xtype: 'toolbar', 
      items: [{ 
       text: 'Add', 
       iconCls: 'icon-add', 
       handler: function(){ 
        // empty record 
        store.insert(0, new MyLodge.model.Member()); 
        rowEditing.startEdit(0, 0); 
       } 
      }, { 
       text: 'Delete', 
       iconCls: 'icon-delete', 
       handler: function(){ 
        var selection = grid.getView().getSelectionModel().getSelection()[0]; 
        if (selection) { 
         store.remove(selection); 
        } 
       } 
      },'-',{ 
       text: 'Save', 
       iconCls: 'icon-save', 
       handler: function(){ 
        store.sync(); 

       } 
      }] 
     }] 
    }); 

    this.callParent(arguments); 
} 

});

回答

4

可以同步

store.sync({ 

     success: function(response) { 
       store.load(); 
      } 
}); 
0

你可能會想打電話store.reload()在回調從store.save()(什麼是store.save()呢?它不是Ext.data.Store接口的一部分)

+0

更新問題的回調加載店:用store.sync()替換store.save() – Kevin 2013-03-10 21:22:32