项目中遇到一个问题,动态添加checkgroup,总是添加不上去,总是会跳出一个问题。
Panel.form.findField('permission').add(items) 无法获取属性“nextSibling”的值: 对象为 null 或未定义。但是在extjs4.0.2版本下是没有问题的。
var Panel = new Ext.form.FormPanel({
bodyStyle: 'position:relative;padding: 5px 5px;',
defaults: {
xtype: 'textfield',
allowBlank: false,
fieldWidth: 60
},
items: [{
name: 'user_id',
readOnly: user_id == undefined ? false : true,
fieldLabel: '用户登录名'
}, {
name: 'user_name',
fieldLabel: '用户姓名'
}, {
hidden: user_id == undefined ? false : true,
name: 'password',
fieldLabel: '密码',
inputType: 'password'
}, {
hidden: user_id == undefined ? false : true,
name: 'confirm',
fieldLabel: '确认密码',
inputType: 'password'
}, {
xtype: 'checkboxgroup',
name: 'permission',
frame: true,
columns: 3,
allowBlank: true,
fieldLabel: '可用权限'
}],
buttons: {
text: "确定",
tabIndex: 1,
iconCls: 'save',
handler: onSaveUser
}, {
text: "取消",
tabIndex: 2,
iconCls: 'close',
handler: function () {
win.close();
}
}]
});
if (user_id) {
Ext.Ajax.request({
url: 'core/WebService.asmx/LoadUserByID',
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
method: 'POST',
jsonData: {
user_id: user_id
},
success: function (response) {
var data = Ext.JSON.decode(response.responseText).d;
Panel.form.findField('user_id').setValue(user_id);
Panel.form.findField('user_name').setValue(data.user_name);
Panel.form.findField('password').setValue(data.password);
Panel.form.findField('confirm').setValue(data.password);
var items = initPermission(data.permission);
userPanel.form.findField('permission').add(items);
if (data.is_manager) {
Panel.form.findField('permission').setVisible(false);
return;
}
}
});
}
else {
var items = initPermission("");
debugger;
userPanel.form.findField('permission').add(items);
}
function initPermission(perms) {
var items = new Array();
if (perms == null) perms = "";
var pms = perms.split(',');
Ext.each(permission, function (m) {