PDA

View Full Version : Use a variable buttongroup/togglegroup name - when creating instance using xtype



caryn
12 Feb 2013, 2:06 PM
Hi

I am trying to create two instances of a ui control - with a button group as follows :
Ext.define('my.pack.Control', {
extend: 'Ext.container.Container',
xtype: 'control-class',
mygroup:'booyah',
items: [
{
type: 'buttongroup',
align: 'left',
alias: 'intervalButtonGroup',
items: [
{
xtype: 'button',
text: '1h',
enableToggle: true,
toggleGroup: mygroup,
},{
xtype: 'button',
text: '6h',
enableToggle: true,
toggleGroup: mygroup,
}]
}]
});

var pcontrol1 = Ext.create('my.pack.Control',{
mygroup: 'var1,
});

var pcontrol2 = Ext.create('my.pack.Control',{
mygroup: 'var2,
});

How can i create the two instances so that the toggle groups are independent ? I want the two controls to be independent so that the two sets of buttons ( four total ) are not all part of the same button group.
I cannot seem to pass in the group name as shown above ..any ideas ? Basically want to be able to namespace the two togglegroup names.

Thanks !!

caryn
12 Feb 2013, 2:26 PM
Should I be overriding the initComponent to create a dynamic toggle group ?
initComponent: function() {
Ext.Array.forEach(this.items.items[0].items.items ,function(mygroup) {
mygroup.toggleGroup = this.initialConfig.namespace;
});
}