PDA

View Full Version : CheckBox - Select all checkbox of a checkboxgroup



marxan
30 Nov 2010, 12:11 AM
Hello,

I have a checkboxgroup with a couple of checkbox, what I would like to do is when the first box is checked the others should be checked too but I have no idea how to proceed to achieve that.

What I've done so far is to use a listener and I guess in my checkAll() function I should retrieve all the checkbox of the group but I don't know how to do.

Thanks for giving me some information to do that.


{
layout: 'column',
items: [
{
columnWidth: .1,
border: 'true',
layout: 'fit',
items:
{
xtype: 'checkboxgroup',
id: 'group-D',
columns: 1,
items: [
{ boxLabel: '<b>D</b>',
name: 'D',
listeners: {
check: checkAll
}
},
{
boxLabel: 'D1',
name: 'D1'
},
{
boxLabel: 'D2',
name: 'D2'
},
{
boxLabel: 'D3',
name: 'D3'
},
{
boxLabel: 'D4',
name: 'D4'
}
]
}
}

Condor
30 Nov 2010, 12:28 AM
You could use:

function checkAll(cb, checked){
var group = Ext.getCmp('group-D');
group.eachItem(function(item){
item.setValue(checked);
});
}
Disclaimer: Completely untested code!

marxan
30 Nov 2010, 1:28 AM
Thanks again Condor

senacle
27 Aug 2018, 10:50 PM
If you come here, here is the code for Ext 6.6.0



function checkAll(cb, checked){
var group = Ext.getCmp('id_annuadCheckAlphabet');
group.eachBox(function(item){
item.setValue(newValue);
});
}