View Full Version : adding checkboxes dynamically to checkboxgroup

5 Jul 2011, 1:05 PM
I want to add checkboxes to my checkboxgroup dynamically.
So, I have a window that has a form that has a checkboxgroup.
On the load event of my store, I push records with 2 fields('name' and 'boxLabel') to an array and then I assign that array to the items property of the checkboxgroup.

arr = [{name:'chk1', boxLabel:'Option 1'}, {name:'chk2', boxLabel:'Option 2'}]
Ext.getCmp('id-of-checkboxgroup').items = arr;

This doesn't work. The items array turns up null.

Please help.

5 Jul 2011, 6:15 PM
I don't believe CheckboxGroup supports adding items dynamically. I think you'll need to destroy the old group and create a new one. It wouldn't be impossible to add them dynamically but, depending on your column configuration, it could be very tricky.

8 Jul 2011, 10:22 AM
Thanks, Skirtle.
Indeed checkboxgroups do not support dynamic additions.
My solution was to create the group, populate it with checkboxes and add it to the form on the store's load event.