View Full Version : Set items of checkboxgroup from db before render

20 Jan 2010, 1:59 AM

I have the following Checkboxgroup:

xtype: 'checkboxgroup',
fieldLabel: 'Usergroups',
id: 'usergroups',
itemCls: 'x-check-group-alt',
// Distribute controls across 3 even columns, filling each column
// from top to bottom before starting the next column
columns: 3,
vertical: true,
items: []
How can I set the items before rendering? I fetch usergroups out of a database.


Lloyd K
20 Jan 2010, 2:21 AM
We do this, we pull the item config down in a JSON array then simply build new items and push them onto an items array which is then fed to items, e.g:

xtype: "checkboxgroup",
fieldLabel: "Track",
columns: [150,150,150],
items: analytics_controls,
tooltipText: DCStorm.IQ.Tooltips.AgencyAdmin_Site_AnalyticsTrack,
tooltipClass: "iq-shared-form-qtip-help"

analytics_controls = [];

// Build Analytics controls
for (var i = 0, len = site_config.traffic_sources.length; i < len; i++) {
var checkbox = new Ext.form.Checkbox({
id: "iq_agencyadmin_site_analytics_" + site_config.traffic_sources[i].id,
boxLabel: site_config.traffic_sources[i].name