// 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();
}
});
extjs2.3 GridPanel样本
最新推荐文章于 2020-06-16 10:32:41 发布