Extjs3.0 中的CheckboxGroup默認不能動態添加item。雖然它繼承了Ext.form.Field,但是卻類似于容器。
CheckboxGroup配置中的items處理生成一個對應的panel,該處理過程只有一次,所以很難對CheckboxGroup進行動態添加。
如需要數據動態創建,試著創建整個CheckboxGroup,而不是動態添加item。
復制代碼 代碼如下:
var unitColumns=[];
for(var i = 0;i < records.length;i++){
unitColumns.push({
boxLabel: records[i].data.A11,
name: records[i].data.A11,
inputValue: records[i].data.A1,
checked: false
});
}
var itemsGroup = new Ext.form.CheckboxGroup({
id:'unitItems',
bodyStyle:'background-color: transparent;margin-top:10px;',
fieldLabel: '選項',
columns: 2,
items: unitColumns
});
Ext.getCmp('OptionsSet').add(itemsGroup);
Ext.getCmp('OptionsSet').doLayout();
新聞熱點
疑難解答
圖片精選