Cyclebutton stops working after I add a menu Item?
When I add menu Items to cycleButton it seems to break the cycle button and I cannot select the newly added buttons...
I had a look here and tried to insert the extra params but it had no effect?
http://www.sencha.com/forum/showthre...ht=cyclebutton
What silly thing have I done to break it?
Code:
var vTotalYear = vCurrentYear - 2009;
var vComponentName = ['btnFiscalYearFrom','btnFiscalYearTo'];
for (i=0;i<vComponentName.length;i++){
var vYearsToDisplay = [];
var component = Ext.getCmp(vComponentName[i]);
for (x = 0;x<=vTotalYear;x++) {
var vYear = 2009 + x;
var vYearVal;
if (vYear == vCurrentYear) {
vYearVal = {
id:'active_'+vComponentName,
text:vYear,
xtype:'menuitem',
checked:true
};
} else {
vYearVal = {
text:vYear,
xtype:'menuitem'
};
}
vYearsToDisplay[x]=vYearVal;
}
component.menu.add(vYearsToDisplay);
component.setActiveItem('active_'+vComponentName);
}
This is working for me in 4.1.2 if....
Hi there,
You code helped me out. I found two ways to solve this problem.
1. I found that if the cycle button is initially configured with a menu and at least one menucheckitem it wires everything up correctly. Then in my code I use the cloneConfig({text: 'my new item'); to create a new item which becomes a member of the same radio group when I call the menu.add(). Of course I'm removing the initially configured item.
Code:
var item = cycle.menu.items.items[0].cloneConfig({text: 'cloned item'});
cycle.menu.add(item);
2. If I follow your example but set the group: 'name of cycle button' then it works too. My guess is that the handler is using the group name to find the Cycle button above it to set the text, etc.
Code:
item = Ext.create('Ext.menu.CheckItem', {
text: 'James Sutton',
checkHandler: cycle.checkHandler,
checked: true,
scope: cycle,
group: 'currentUser'
});
cycle.menu.add(item);