PixelMuse PixelMuse - 1 year ago 183
Javascript Question

ExtJS - Loop through CheckBoxGroup

I would like to get all of the checked items in a checkboxgroup that is part of a formpanel. Ultimately they would be saved back to database as a string, comma separated value format.

Thanks for any guidance or assistance you can provide.

Here is how I have my group defined:

new Ext.form.CheckboxGroup({
id: 'newId',
fieldLabel: 'Group A',
name: 'broker',
allowBlank: false,
columns: 1,
items: [{
boxLabel: 'All',
name: 'all',
id: 'null'
boxLabel: 'FS',
name: 'fs',
id: '1'
boxLabel: 'Royal A',
name: 'ra',
id: '2'
boxLabel: 'Point',
name: 'sp',
id: '6'

Answer Source

Use CheckBoxGroup's getValue() method. From the API docs:


Gets an array of the selected Ext.form.Checkbox in the group.

Returns: An array of the selected checkboxes.

You can then call join(",") on the returned Array to get a comma-separated list.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download