即使在过滤后重新加载存储,网格也不会更改

时间:2013-04-07 10:26:03

标签: extjs extjs4.1

我想要一个在删除任何行后会更改或重新加载的网格,并检索那些具有相同成员ID的行。为此,我添加了过滤器。删除任何行后,我再次使用过滤器回调商店。我的商店过滤得很好,但网格无法显示......它保留了之前的显示......

Ext.define('${pkgName}.v02x001001.SV02X00100101' , {
extend    : 'Ext.grid.Panel',
alias     : 'widget.sv02x00100101',
id        : 'sv02x00100101',
border    : true,
modal     : true,
height    : 300,
width     : 455,
viewConfig: {
    stripeRows    : true,
    forceFit      : true,
    emptyText     : 'No Records to display',
    listeners     : {
        viewready : function(v) {                    
            var store = Ext.data.StoreManager.get('S02X001001');               
            store = !store ? Ext.create("S02X001001") : store;
            var value = Ext.getCmp('member-sv02x00100104').getValue(),
            filters   = new Array();
            store.clearFilter();
            store.filter('member', value);
            filters.push({
                property : 'member', 
                value    : value
              });
            store.loadPage(1, {
                filters  : filters
             }); 
        }
    }
},
initComponent: function() {
    this.store  = 'S02X001001';     

    this.tbar= Ext.create('Ext.ux.StatusBar', {            
        topBorder       : false,
        statusAlign     : 'right',
        items    : [{
            xtype       :'button',
            text        : 'ADD',
            icon        : "${resource(dir: 'images', file: 'ADD01003.png')}",
            listeners   : {
                click   : this.onNewAddress
                }
        },'-']
    });

    this.columns = [
    {
        text            : 'Address Line 1',
        dataIndex       : 'addressline1', 
        sortable        : false,
        flex            : 1
    },{
        text            : 'Address Line 2',
        dataIndex       : 'addressline2',
        sortable        : false,
        width           : 170
    },{
        menuDisabled    : true,
        sortable        : false,
        id              : 'deletee',
        xtype           : 'actioncolumn',            
        width           : 22,            
        items           : [{
            icon        : "${resource(dir: 'images', file: 'DEL01005.png')}",
            tooltip     : 'Delete This?',
            scope       : this,
            handler     : function(grid, rowIdx, colIdx) {
                var record = grid.getStore().getAt(rowIdx);
                var conId  = record.data.id
                this.onDeleteClick(conId);
            }
        }]
    }]; 
    this.callParent(arguments);
},

onNewAddress: function(btn, e, eOpts){
    var view=Ext.widget('sv02x00100102');
    view.show();
    var a = Ext.getCmp('member-sv02x00100104').getValue();
            Ext.getCmp('member-sv02x00100102').setValue(a);
},
onDeleteClick:function(conId){
       Ext.MessageBox.show({
        title       : 'Delete',
        msg         : 'Really want to delete ?',
        icon        : Ext.Msg.WARNING,
        buttons     : Ext.MessageBox.YESNO,
        buttonText  :{ 
            yes: "Delete", 
            no : "No" 
        },
        scope         : this,
        animateTarget : 'deletee',
        fn: function(btn, dbQty){
            if(btn == 'yes'){
                var registration = Ext.create('${appName}.model.M02X001001',{
                    id : conId
                });
                var store = this.getStore();
                registration.destroy({
                    scope   : this,
                    success : function(model, operation) { 
                        if(model != null){
                        var store = Ext.data.StoreManager.get('S02X001001');               
                        store = !store ? Ext.create("S02X001001") : store;
                        var value = Ext.getCmp('member-sv02x00100104').getValue(),
                        filters   = new Array();
                        store.clearFilter();
                        store.filter('member', value);
                        filters.push({
                            property : 'member', 
                            value    : value
                          });
                        store.loadPage(1, {
                            filters  : filters
                        }); 
                       }
                    },
                    failure: function(){
                        console.log('Unable to delete');
                    }
                });           
            }                         
        }         
    });                    
 }      

});

如何检索其余的相关行........

这是我的商店..........

Ext.define('${pkgName}.S02X001001', {
extend    : 'Ext.data.Store',
model     : '${appName}.model.M02X001001',
idProperty: 'id',
autoLoad  : true,
autoSync  : true,
filterParam: 'query',
remoteSort: true,
proxy     : {
    type    : 'ajax',
    noCache : false,
    limitParam: 'limit',
    startParam: 'start',
    url : '${createLink(controller:'C02x001001', action: 'store')}',
    reader:{
        type            : 'json',
        root            : 'data',
        totalProperty   : 'total',
        successProperty : 'success',
        messageProperty : 'message',
        implicitIncludes: true
    },
    simpleSortMode  : true
},
sorters: [{
    property: 'id', 
    direction: 'asc'
}]

});

1 个答案:

答案 0 :(得分:1)

应自动刷新网格视图, 但您可以通过手动方式刷新视图:

使用方法getView()。refresh(); 尝试:

Ext.getCmp('sv02x00100101').getView().refresh();