function fnEditGoods() {
var editGoodsForm = new Ext.FormPanel
(
{
labelWidth: 75,
frame: true,
width: 580,
waitMsgTarget: true,
reader: new Ext.data.JsonReader(
{ root: 'data' },
[{ name: 'GoodsID', mapping: 'GoodsID', type: 'int' },
{ name: 'GoodsName', mapping: 'GoodsName', type: 'string' },
{ name: 'GoodsCode', mapping: 'GoodsCode', type: 'string' },
{ name: 'GoodsModel', mapping: 'GoodsModel', type: 'string' },
{ name: 'GoodsStandard', mapping: 'GoodsStandard', type: 'string' },
{ name: 'InPrice', mapping: 'InPrice', type: 'string' },
{ name: 'MUnit', mapping: 'MUnit', type: 'string' },
{ name: 'DUnit', mapping: 'DUnit', type: 'string' },
{ name: 'UnitRate', mapping: 'UnitRate', type: 'string' }
]),
items:
[
{
layout: 'column',
border: false,
items:
[
{
columnWidth: .5,
layout: 'form',
border: false,
items:
[
{
xtype: 'textfield',
fieldLabel: ' 物料编号',
labelStyle: 'width:90px',
width: 170,
name: 'GoodsCode',
allowBlank: false,
blankText: '必填'
},
{
xtype: 'textfield',
fieldLabel: ' 规格',
labelStyle: 'width:90px',
width: 170,
name: 'GoodsStandard'
},
{
xtype: 'textfield',
fieldLabel: ' 计划价格',
labelStyle: 'width:90px',
width: 170,
name: 'InPrice',
allowBlank: false,
blankText: '必填'
}, {
xtype: 'textfield',
fieldLabel: ' 主计单位',
labelStyle: 'width:90px',
width: 170,
name: 'MUnit',
allowBlank: false,
blankText: '必填'
}
]
},
{
columnWidth: .5,
layout: 'form',
border: false,
items:
[
{
xtype: 'textfield',
fieldLabel: ' 物料名称',
labelStyle: 'width:90px',
width: 170,
name: 'GoodsName',
allowBlank: false,
blankText: '必填'
},
{
xtype: 'textfield',
fieldLabel: ' 型号',
labelStyle: 'width:90px',
width: 170,
name: 'GoodsModel'
},
{
xtype: 'textfield',
fieldLabel: ' 比率',
labelStyle: 'width:90px',
width: 170,
name: 'UnitRate',
allowBlank: false,
blankText: '必填'
},
{
xtype: 'textfield',
fieldLabel: ' 辅计单位',
labelStyle: 'width:90px',
width: 170,
name: 'DUnit',
allowBlank: false,
blankText: '必填'
},
{
xtype: 'hidden',
fieldLabel: 'Label',
anchor: '100%',
name: 'GoodsID' }
]
}
]
}
],
buttons:
[
{
id: 'btnOk',
text: '确 定',
handler: function() {
//如果验证合法
if (editGoodsForm.form.isValid()) {
//弹出效果
Ext.MessageBox.show
(
{
msg: '正在保存,请稍等...',
progressText: 'Saving...',
width: 300,
wait: true,
waitConfig: { interval: 200 },
icon: 'download',
animEl: 'saving'
}
);
setTimeout(function() { }, 10000);
//提交到服务器
editGoodsForm.form.submit
(
{
url: 'UI/SysSet/GoodsManageSet.aspx?opera_name=EditGoods', //提交的页面路径
method: 'post', //提交方式为post
//提交成功的回调函数
success: function(form, action) {
var flage = action.result.success;
//如果服务器端传过来的数据为true则表示登录成功
if (flage == true) {
Ext.MessageBox.alert('恭喜', '保存成功!');
strGoodsInfo.reload(); //重新加载Grid
editGoodsWin.hide();
}
},
//提交失败的回调函数
failure: function() {
Ext.Msg.alert('错误', '保存失败!');
}
}
);
}
}
},
{
text: '取 消',
handler: function() {
editGoodsWin.hide();
}
}
]
}
);
var strID = goodsGridUi.getSelectionModel().getSelected().data.GoodsID;
editGoodsForm.form.load({
url: 'UI/SysSet/GoodsManageSet.aspx?opera_name=Get&GoodsID=' + strID, //提交的页面路径
waitMsg: '正在载入数据...',
success: function(form, action) {
},
failure: function(form, action) {
xt.Msg.alert('编辑', '载入失败');
}
});
//定义窗体
var editGoodsWin = new Ext.Window
(
{
layout: 'fit',
width: 700,
height: 300,
collapsible: true, //允许缩放条
closeAction: 'hide',
closable: true,
plain: true,
modal: 'true',
title: '新增物料',
items: editGoodsForm }
);
//显示窗体
editGoodsWin.show();
};
右击editgrid行后,弹出菜单中执行此函数,报错"错误: 'this.el' 为空或不是对象",
求高手解答
1.把你要执行的内容放到外面去,每次都要创建window,form。先整理一下试试
2.form中还搞一个JsonReader干啥。要规范些
reader: new Ext.data.JsonReader(
{ root: 'data' },
[{ name: 'GoodsID', mapping: 'GoodsID', type: 'int' },
{ name: 'GoodsName', mapping: 'GoodsName', type: 'string' },
{ name: 'GoodsCode', mapping: 'GoodsCode', type: 'string' },
{ name: 'GoodsModel', mapping: 'GoodsModel', type: 'string' },
{ name: 'GoodsStandard', mapping: 'GoodsStandard', type: 'string' },
{ name: 'InPrice', mapping: 'InPrice', type: 'string' },
{ name: 'MUnit', mapping: 'MUnit', type: 'string' },
{ name: 'DUnit', mapping: 'DUnit', type: 'string' },
{ name: 'UnitRate', mapping: 'UnitRate', type: 'string' }
])