extjs2.3 GridPanel样本

// JScript 文件
demoSetting=Ext.extend(Ext.grid.GridPanel,{
        constructor:function(config){
            
            this.selModel = new Ext.grid.CheckboxSelectionModel();	
            Ext.apply(this,config);
            this.store = new Ext.data.Store({
			        proxy:new Ext.data.HttpProxy({url:IntegralMoneySetting.store_url}),
			        autoLoad:true,
			        baseParams:{action:"getPointsMoneyGridList"},			
			        reader:new Ext.data.JsonReader({
				        //totalProperty:"totalCount",
				        root:"data"
			        },Ext.data.Record.create([
			            {name:"AmountTypeID"},
			            {name:"money"},
			            {name:"points"}
			         ]))
		     });
		     this.colModel=new Ext.grid.ColumnModel({
			        columns:[new Ext.grid.RowNumberer(),
			        this.selModel,
	                {
				        header:"金额",
				        align:"center",
				        dataIndex:"money"
			        },{
				        header:"积分",
				        align:"center",
				        dataIndex:"points"
			        }
		     ]});
            <pre name="code" class="javascript">                demoSetting.superclass.constructor.call(this,{  
                    title:"积分金额设置",
                    enableColumnMove:false,	
                    enableHdMenu:false,
                    //enableColumnResize:false,
                    stripeRows:true,			
                    loadMask:{msg:"数据加载中,请稍等"},
                    //viewConfig: {forceFit:true},			
                    frame:true,	
                    tbar:[{
		                    text:"添加",
		                    //disabled:true,
		                    iconCls:"addicon",
		                    handler:function(){
		                        var _win = new AddIntegralMoneySettingWin();
		                        _win.on("submit",function(){ this.store.reload();},this);
		                        _win.show();
		                        //_win.on("submit",function(){ this.store.reload();},this);
                            },
		                    scope:this
	                    },"-",{
	                        text:"修改",
	                        disabled:true,
	                        iconCls:"editicon",
	                        handler:this.onShowMIMSettingWin,
	                        scope:this
	                    },"-",{
		                    text:"删除",
		                    disabled:true,
		                    iconCls:"deleteicon",
		                    handler:this.onDeleteRecord,
		                    scope:this
	                    },"-",{
		                    text:"刷新",
		                    iconCls:"refreshicon",
		                    handler:function(){ this.store.reload()},
		                    scope:this
	                    }]
            }); 
            this.selModel.on("rowselect",this.onSetToolBarState,this);  
            this.selModel.on("rowdeselect",this.onSetToolBarState,this);
        },
        onShowMIMSettingWin:function(){
		    var _selRecords = this.selModel.getSelections();
		    if(_selRecords.length == 0){
		        ErrMsg("必须选择一条记录才能修改!");
		        return false;
	        }
		    var _editWin = new ModifyIntegralMoneySettingWin();
		    
		    _editWin.show();
		    _editWin.on("submit",function(){ this.store.reload();},this);
		    _editWin.form.getForm().loadRecord(_selRecords[0]);
		    
		},
		onDeleteRecord:function(){
		    var _selArr = this.selModel.getSelections();
		    if(_selArr.length == 0){
		        ErrMsg("必须选择一条记录才能删除!");
		        return false;
	        }
		    Ext.Msg.confirm("系统提示","你是否确定删除记录",this.onDelPayAmountType,this);
		},
		onDelPayAmountType:function(btn){
		    if(btn == "yes"){
			    //this.el.mask("删除中...");
			    //var _sr=this.getSelectRecord(); 单选
			    var _selArr = this.selModel.getSelections();   //复选
			    
			    var _this=this;
                var successFn=function(pResult)
                {
                    for(var i=0;i<_selArr.length;i++){
    					_this.store.remove(_selArr[i]);
    				}
                    //_this.store.remove(_sr);
                    _this.onRefresh();
                }
                var pFailureFn = function(pResult)
                {
    				Ext.Msg.alert("系统提示","删除失败");
    			}
                Ext.Ajax.request({
                   url: 'demo/IntegralMoneySettingSave.aspx',
                   success: successFn,
                   failure: pFailureFn,
                   headers: {
                       'my-header': 'foo'
                   },
                   params: {action:"DelIntegralMoneySave", delIDs:this.getSelectedIDs() }
                });
			     
		    }
	    },
	    getSelectedIDs:function(){
    	    var _selArr = this.selModel.getSelections();
    	    var _selIDs = [];
    	    for(var i=0;i<_selArr.length;i++){
    		    _selIDs.push(""+_selArr[i].get("AmountTypeID")+"");
    	    }
    	    return _selIDs.join(",");
        },
		onSetToolBarState:function(){
		    var _selCount = this.selModel.getCount();
		    
		    if(_selCount == 1){
			    this.getTopToolbar().items.item(2).setDisabled(false);
			}else
			{
			    this.getTopToolbar().items.item(2).setDisabled(true);
			    this.getTopToolbar().items.item(4).setDisabled(true);
			}
			if(_selCount > 0)
		    {
		        this.getTopToolbar().items.item(4).setDisabled(false);
		    }
		},
		onRefresh:function(){
    	    this.store.reload();
        }
          
});
 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值