Sammie 2010-08-30 09:17
浏览 274
已采纳

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条回答 默认 最新

  • iteye_18964 2010-09-02 13:02
    关注

    result.success为true后store重新load

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示