ExtJS - Loop through CheckBoxGroup

extjs, javascript

Solution

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

getValue():

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.

Problem

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' }] }) ```

Original source