insert = function(ds) {
Ext.QuickTips.init();// 用来提示信息
Ext.form.Field.prototype.msgTarget = 'side';// 统一指定错误提示方式
var userTxt = new Ext.form.TextField({
fieldLabel : '用户名称',
name : 'admin.username',
anchor : '98%'
})
var pwdTxt = new Ext.form.TextField({
fieldLabel : '用户密码',
name : 'admin.password',
anchor : '98%'
})
var myForm = new Ext.form.FormPanel({
labelAlign : 'right',
labelWidth : 60,
frame : true,
items : [{
xtype : 'fieldset',
title : '增加用户',
autoHeight : true,
items : [{// 第1行
layout : 'column',
items : [{
columnWidth : 1,
layout : 'form',
items : userTxt
}]
}, { // 第2行
layout : 'column',
items : [{
columnWidth : 1,
layout : 'form',
items : pwdTxt
}]
}]
}],
buttons : [{
text : '提交',
handler : function() {
if (myForm.getForm().isValid()) {
Ext.MessageBox.show({
msg : '正在提交,请稍等...',
progressText : 'Saving...',
width : 300,
wait : true,
waitConfig : {
interval : 200
},
icon : 'download',
animEl : 'saving'
});
myForm.form.submit({
url : "saveAdmin.action",
method : "POST",
success : function(form, action) {
// var flag = action.result.success;
// if (flag == "true") {
Ext.MessageBox.alert("恭喜","提交成功!");
insert_Win.close();
ds.reload();
// }
},
failure : function(form, action) {
Ext.MessageBox.alert("提示!", "提交失败!");
}
});
}
}
}, {
text : '重置',
handler : function(){
myForm.form.reset();
}
}]
});
var insert_Win = new Ext.Window({
plain : true,
layout : 'form',
resizable : true, // 改变大小
draggable : true, // 不允许拖动
closeAction : 'close',// 可被关闭 close or hide
modal : true, // 模态窗口
width : 200,
autoHeight : true,
title : '增加记录',
items : [myForm],// 嵌入数据
buttonAlign : 'center',
loadMask : true
});
insert_Win.show();
}