代码如下:
但第一次打开更新窗口是没有错误[img]http://dl2.iteye.com/upload/attachment/0089/6237/3a6ed15c-e7e6-30a0-9fad-c75e9df7485d.png[/img],
第二次打开时form里的部分东西会显示两次,而且会丢失表单里的数据
[img]http://dl2.iteye.com/upload/attachment/0089/6239/b322266c-0ad6-3964-a5ba-27e71649a812.png[/img]
:
[code="java"]{
text:'更新设备',
tooltip:'更新设备',
iconCls:'update',
ref: '../updateButton',
disabled: true,
handler: function(){
var record = grid4.getSelectionModel().getSelected();
var form = new Ext.form.FormPanel({
baseCls: 'x-plain',
labelWidth: 55,
autoDestroy : true,
layout: {
type: 'form',
align: 'stretch' // Child items are stretched to full width
},
defaults: {
xtype: 'textfield'
},
items: [{
value:record.get("deviceid"),
plugins: [ Ext.ux.FieldLabeler ],
id: 'deviceInfo.deviceid',
hidden:true
//hideLable:true
},{
value:record.get("devicealias"),
plugins: [ Ext.ux.FieldLabeler ],
fieldLabel: '设备名称',
id: 'deviceInfo.devicealias'
},
{
value:record.get("deviceip"),
plugins: [ Ext.ux.FieldLabeler ],
fieldLabel: '设备IP',
id: 'deviceInfo.deviceip'
},{
value:record.get("devicemac"),
plugins: [ Ext.ux.FieldLabeler ],
fieldLabel: '设备MAC',
id: 'deviceInfo.devicemac'
},
]
});
//初始化设备类型
var typesStore = new Ext.data.JsonStore({
url:'./initDeviceTypes.action',
fields: ['index','type']
});
typesStore.load();
var deviceTypesCombo=new Ext.form.ComboBox({
xtype : 'combo',
fieldLabel : '设备类型',
store : typesStore,
editable : false,
allowBlank : false,
mode : 'local',
triggerAction : 'all',
editable : false,
hiddenName : 'deviceInfo.devicetypeid',//要想向后台传递valueField必须设置此项
valueField : 'index',
displayField : 'type'
});
form.add(deviceTypesCombo);
var w = new Ext.Window({
title: '更新设备',
collapsible: true,
maximizable: true,
width: 500,
height: 400,
minWidth: 300,
minHeight: 200,
autoDestroy : true,
layout: 'fit',
plain: true,
bodyStyle: 'padding:5px;',
buttonAlign: 'center',
items: form,
buttons: [{
text: '提交',
handler : function(){
form.getForm().submit({
url:'./updateDevice.action',
method: 'post',
waitTitle : '请等待' ,
waitMsg: '正在提交中',
success:function(form,action){
if(action.result.res==0){
w.hide();
location.href="./device/listDevices.jsp";
Ext.Msg.alert('提示',"修改成功");
}else{
Ext.Msg.alert('提示','修改失败!');
w.hide();
}
},
failure:function(form,action){
Ext.Msg.alert('提示','修改失败!');
w.hide();
}
});
}
},{
text: '取消',
handler : function(){
w.hide();
form.close();
}
}]
});
w.show();
}
}[/code]