1. 创建一个Store
this.cashStuStore = new Ext.data.Store({
autoLoad : false,
proxy : new Ext.data.HttpProxy({
url : urlPath+'xxx.php?action=xxx'
}),
reader : new Ext.data.JsonReader({
root : 'data',
fields : [
{ name : 'ID' },
{ name : 'FIRSTNAME' },
{ name : 'LASTNAME' },
{ name : 'STEP_ALL' }
]
}),
listeners : {
scope : this,
load : function(oStore,aRecords) {
//在load之后 动态赋值
}
}
});
2. 在load之后 动态赋值
var obj =this;
var itemsInGroup = [];
this.cashStuStore.each( function(record) {
var label = record.data.LASTNAME + ', ' + record.data.FIRSTNAME;
var disabled = false;
var checked = false;
if(stuId == record.data.ID){
checked = true;
}
itemsInGroup.push( new Ext.form.Checkbox({
boxLabel: label,
name: 'stuChk',
disabled : disabled,
checked : checked,
inputValue: record.data.ID
}));
});
this.fromField_stu_chk = new Ext.form.CheckboxGroup({
name : 'stuChk',
xtype: 'checkboxgroup',
fieldLabel: _('EDSR_STUDENT_NAME'),
itemCls: 'x-check-group-alt',
columns: 1,
width : 350,
items: itemsInGroup
});
3. 将创建好的checkgroup放到一个Panel中,再放入window中,win.show();
使用的时候直接store.reload();就可以了.