当前位置: 代码迷 >> Web前端 >> Ext 依据store动态获取checkbox
  详细解决方案

Ext 依据store动态获取checkbox

热度:132   发布时间:2012-10-08 19:54:56.0
Ext 根据store动态获取checkbox
(1)首先获取checkbox的列表:
getBusinessStore: function(){
var store = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({url: 'source.do?m=getBusinessList'}),
root : "businessList",
autoLoad : false,
fields : ['value', 'text'],
totalProperty : "totalRows"
});
store.load();

return store;

}

(2)是store on load之后拼接panel中的items中的checkbox:
var businesses="[";
var count = businessStore.getCount();

for(var i=0; i<count; i++){
businesses += "{boxLabel: '" +businessStore.getAt(i).get('text')+ "', inputValue: '"+i+"', id: '"+businessStore.getAt(i).get('value')+"'}";
if(i < count-1){
businesses = businesses + ",";
}
}
businesses +="]";
businesses = Ext.decode(businesses);
var businessPanel = new Ext.FormPanel({
border: false,
layout: 'form',
bodyStyle: 'padding-right:5px;padding-left:5px; padding-top:5px;',
defaultType: 'checkbox',
items: [{
xtype: 'fieldset',
title: '业务列表',
defaultType: 'checkbox',
items: businesses

}]
});
  相关解决方案