ExtJs操作完自动刷新

[color=red]就是用Extjs中的表格进行删除操作后,表格怎么自动指定显示刚添加的数据[/color]

Ext.ux.baseinfo.w_whyzl = Ext.extend(Ext.grid.EditorGridPanel, {
/**
* @cfg {String} url
* 请求的url
/
url: 'getAllWhyzl.action', // 初始化URL
/
*
* @cfg {Integer} pageSize
* 每页显示条数,默认20条
/
pageSize: 2,
/
*
* @cfg {String} valueField
* ComboBox或ComboTree存储显示文本的属性名。
*/
displayField: 'name',

initComponent: function(){
    this.buildStore();
    this.buildTBar();
    this.buildBBar();
    this.buildColModel();
    this.view = new Ext.ux.grid.MSortGridView();
    Ext.apply(this, {

        sm:new Ext.grid.RowSelectionModel()
    }); 
    this.ds.load( {
        params : {
        start : 0,
        limit : this.pageSize
        }
    })
    Ext.ux.baseinfo.w_whyzl.superclass.initComponent.call(this);
},
init: function(){       
    //this.initRight();

},
buildTBar: function(){
    this.btnAdd = new Ext.Button({
        id: 'btnAdd',
        text: '增加',
        iconCls: 'icon-add',
        handler: this.addHandler
    });
    this.btnDelete = new Ext.Button({
        id: 'btnDelete',
        text: '删除',
        iconCls: 'icon-delete',
        handler: this.delHandler
    });
    this.btnSave = new Ext.Button({
        id: 'btnSave',
        text: '保存',
        iconCls: 'icon-save',
        handler : this.saveHandler
    });
    this.tbar = new Ext.Toolbar({
        defaults: {
            width: 40,
            scope: this,
            disabled: false
        },
        items: [this.btnAdd, this.btnDelete, this.btnSave]
    });
},

buildBBar: function(){
    this.bbar = new Ext.PagingToolbar({
        store: this.ds,
        pageSize: this.pageSize,
        displayInfo: true
    });
},
buildStore:function(){
     this.ds=new Ext.data.Store( {
            proxy : new Ext.data.HttpProxy( {
                url : 'getAllWhyzl.action'
                }),
                baseParams: {
                    start: 0,
                    limit: this.pageSize
                },
                reader : new Ext.data.JsonReader( {
                    root : 'results',
                    totalProperty : 'totalCount',
                    id : 'iWhyid',
                    successProperty : '@success'
                    }, [ {
                    name : 'whyzl.iWhyid',
                    mapping : 'IWhyid'
                    }, {
                    name : 'whyzl.cWhyno',
                    mapping : 'CWhyno'
                    }, {
                    name : 'whyzl.cWhyname',
                    mapping : 'CWhyname'
                    }, {
                    name : 'whyzl.iDeptid',
                    mapping : 'IDeptid'
                    }, {
                    name : 'whyzl.cPhone',
                    mapping : 'CPhone'
                    }, {
                    name : 'whyzl.cWhyStatus',
                    mapping : 'CWhyStatus'
                    }])
                });
},
buildColModel: function(){
        this.cm= new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
        id : 'id',
        header : '内编号',
        dataIndex : 'whyzl.iWhyid',
        width : 40
        }, {
        header : "人员编号",
        dataIndex : 'whyzl.cWhyno',
        width : 80,
        sortable : true,
        locked : false
        }, {
        header : "人员姓名",
        dataIndex : 'whyzl.cWhyname',
        editor:new Ext.form.TextField({
            allowBlank:false
        }),
        width : 120
        },{
        header : "人员类型",
        dataIndex : 'whyzl.iDeptid',
        editor:new Ext.form.TextField({
            allowBlank:false
        }),
        width : 120
        }, {
        header : "联系方式",
        dataIndex : 'whyzl.cPhone',
        editor:new Ext.form.TextField({
            allowBlank:false
        }),
        width : 120
        }, {
        header : "工作状态",
        dataIndex : 'whyzl.cWhyStatus',
        width : 120
        }
        ]);
},
addHandler:function(){
    this.addWhyzl=new Ext.ux.baseinfo.w_addWhyzl({

    });
    this.addWhyzl.show();
},
delHandler:function(){
    this.count = this.getSelectionModel().getCount();
    if (this.count==0) {
         Ext.Msg.alert('提示','请选择要删除的资料');
    }else if(this.count>1){
         Ext.Msg.alert('提示','每次只能并且只能删除一个人员资料');
    }else{
        var msg=0;
        var _record =this.getSelectionModel().each(function(rec){
             msg=rec.get('whyzl.iWhyid');
        });
        Ext.MessageBox.confirm('确认删除', '你确认要删除这条数据吗?', function(btn) {
            if (btn == "yes") {
                Ext.Ajax.request({
                    url:'deleteWhyzl.action',
                    params:{
                         iWhyid:msg
                           },
                    method:'POST',
                    success:function(response,options){
                               var result=Ext.decode(response.responseText);
                               if(result.success){
                                   Ext.Msg.alert('提示','删除部门信息成功!');

                               }else{
                                   Ext.Msg.alert('提示','删除部门信息失败!');
                               }
                           },
                     failure:function(response,options){

                               Ext.Msg.alert('提示','删除部门信息请求失败!');
                           }  

                });

            }
        });
    }   
    。。。。。。。。。。

1个回答

result.success为true后store重新load

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!