我使用extjs4,我要根據我的JSON對象添加的複選框組,爲JSON創建的CheckBox對象
JSON
{"Provider":[{"id":3,"name":"Beta House","npi":0,"taxId":0,
"address":{
"state":{"id":"1","stateName":"Alabama","code":"AL"},
"zipcode":0,"country":"USA","email":"[email protected]"},
"type":"CP","LabProvider":[],"ListOfProvider":[]}]}
ExtJS的 Ext.define('providerList ',{ extend:'Ext.data.Model', fields:['id','name'] });
var provider = Ext.create('Ext.data.Store', {
model: 'providerList',
autoLoad: true,
proxy: {
type: 'ajax',
url : url+'/lochweb/loch/clinicalProvider/getAll',
reader: {
type: 'json',
root: 'Provider'
}
}
});
面板
var checkboxconfigs = [];
provider.each(function(record) {
checkboxconfigs.push(
{
boxLabel: 'record.id',
name: 'record.name'
})
});
var checkboxes = new Ext.form.CheckboxGroup({
fieldLabel:'Providers',
columns:2,
items:checkboxconfigs
});
var patientProvider = new Ext.FormPanel({
renderTo: "patientProvider",
frame: true,
title: 'Association',
bodyStyle: 'padding:5px',
width: 500,
items: [{
checkboxes
}],
});
有一個在form.How沒有複選框從JSON商店填充複選框
嗨感謝您的評論,我做了你的建議,但它沒有works.The代碼如下,var items = []; ) });提供程序.each(函數(記錄){ ) }); – user1321824
items數組在注滿box標籤和name.so後仍爲空,因此表單中沒有複選框。 – user1321824
我沒有要查詢的網址,所以我試圖向商店添加一條記錄,並且工作正常。你可以仔細檢查Ajax商店嗎?創建後是否有數據? –