【问题标题】:Sencha ExtJs Grid refresh after saving storeSencha ExtJs Grid 保存存储后刷新
【发布时间】:2013-03-12 20:45:27
【问题描述】:

我有一个带有工具栏按钮的 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);
}

});

【问题讨论】:

    标签: extjs


    【解决方案1】:

    您可以在同步的回调中加载存储

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

    【讨论】:

      【解决方案2】:

      您可能希望在来自store.save() 的回调中调用store.reload()(到底什么是store.save()?它不是Ext.data.Store 接口的一部分)

      【讨论】:

        猜你喜欢
        • 2012-05-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多