var editForm = new Ext.form.FormPanel({
labelWidth: 80,
buttonAlign: 'center',
frame:true,
width: 490,
reader: reader,
items: [{
xtype: 'textfield',
fieldLabel: '用户编码',
name: 'user_code',
readOnly:true,
fieldClass : "background-color:red;",
value: record.get('user_code')
},{
xtype: 'textfield',
fieldLabel: '用户名称',
name: 'user_name',
readOnly:true,
value: record.get('user_name')
},{
xtype: 'textfield',
hidden: true,
name: 'curYear',
id:'curYear',
value:curYear
}],
buttons: [{
text: '保存',
handler: function() {
//首先得到itemsGroup的items 然后循环得到被选择的items的inputValue
var ids = [];
var cbitems = itemsGroup.items;
for (var i = 0; i < cbitems.length; i++) {
if (cbitems.itemAt(i).checked) {
ids.push(cbitems.itemAt(i).inputValue);
}
}
editForm.getForm().submit({
clientValidation: true,
waitMsg: '请稍等...',
waitTitle: '提交中',
url: 'SaveUserRoleServlet',
//可以在submit里边添加参数奖checkbox的值传到后台,后台只需接收ids即可
params: {
ids: ids
},
method: 'GET',
success: function(form, action) {
Ext.Msg.alert('提交', '保存成功!');
},
failure: function(form, action) {
Ext.Msg.alert('提交', '保存失败!');
}
}
);
}
}]
});
//itemsGroup 动态生成选项示例
itemsGroup = new Ext.form.CheckboxGroup({
fieldLabel: '选择权限',
name:'sysapp_ids',
width:430,
itemCls : 'x-check-group-alt',
columns : 3,
id:'sysapp_ids',
items : myCheckboxItems
});
var myCheckboxItems = [];
var myCheckboxItemsTemp = [];
var AllSysApp=[{appName:'支撑平台(001)',appId:'001'},
{appName:'资金监控(211)',appId:'211'},
{appName:'集散账户总账(033)',appId:'033'},
{appName:'OA系统(141)',appId:'141'}];
for (var i = 0; i < AllSysApp.length; i++) {
var boxLabel = AllSysApp[i].appName;
var appId = AllSysApp[i].appId;
myCheckboxItems.push({
boxLabel : boxLabel,
name : 'sysapp_id',
inputValue : appId,
checked: false
});
}