PDA

View Full Version : how to change checkboxgroup's items dynamic?



zzw0598
28 Dec 2009, 8:35 AM
var cldCheckBoxs = new Ext.form.CheckboxGroup({
xtype: 'checkboxgroup',
columns: 10,
items: [
{boxLabel: '1', name: '1',inputValue: '1'},{boxLabel: '2', name: '2',inputValue: '2'},{boxLabel: '3', name: '3',inputValue: '3'},
{boxLabel: '4', name: '4',inputValue: '4'}
]});


hi ,everyone , give a checkboxgroup like this,and I want to add a checkbox into the checkboxgroup.

with cldCheckBoxs.items.add( {boxLabel: '5', name: '5',inputValue: '5'}); or clkCheckBoxs.items.push({boxLabel: '5', name: '5',inputValue: '5'}); not works.

but cldCheckBoxs.items.items.push({boxLabel: '5', name: '5',inputValue: '5'}); works.
however, it doesn't show in the checkboxgroup ,even if I use cldCheckBoxs.doLayout();
or use it's parent's doLayout.

any one help me?

Condor
28 Dec 2009, 8:41 AM
Actually, you have to do both:

var items = checkboxGroup.items,
columns = checkboxGroup.panel.items,
column = columns.itemAt(items.getCount() % columns.getCount()),
checkbox = column.add({...});
items.add(checkbox);
checkboxGroup.doLayout();

(assumes config options columns != 'auto' and vertical != true)

zzw0598
28 Dec 2009, 4:59 PM
thanks, it works!