-
28 Jun 2011 5:56 AM #1
text of selected item on cyclebutton isn't shown
text of selected item on cyclebutton isn't shown
Hello,
i've searched on this site (and the docs) but i couldn't solve my problem...
I want to check if the menu of a splitbutton contains a item. If not it should be added.
In the end the item should be selected.
Here my code:
So the item is available and i can select it in the GUI.Code:else if (component.xtype == 'cycle') { var menuItem = {text: val, group: 'land', xtype: 'menucheckitem'}; if (component.menu.items.findIndex('text', menuItem.text) < 0) { component.menu.add(menuItem); } }
But when it is selected the text of the previous-selected item is shown.
Also i want to set it selected (via code).
How can i solve this?
Thanks in advance
-
28 Jun 2011 3:29 PM #2
Best place to find the answers to questions like this is the ExtJS source code.
From doing a bit of digging it seems that there are some properties set on the menu items when the button is first created and it doesn't make any attempt to cope with adding new items. You can add those properties yourself with something like this:
Code:if (component.menu.items.findIndex('text', val) === -1) { var item = component.menu.add({ checkHandler: component.checkHandler, group: 'land', itemIndex: component.itemCount++, scope: component, text: val, xtype: 'menucheckitem' }); component.setActiveItem(item); }
-
28 Jun 2011 11:07 PM #3
Thank you - that works fine

Here my code:
Code:else if (component.xtype == 'cycle') { var item; var idx = component.menu.items.findIndex('text', val) if (idx === -1) { item = component.menu.add({ checkHandler: component.checkHandler, group: 'land', itemIndex: component.itemCount++, scope: component, text: val, xtype: 'menucheckitem' }); } else if (idx >= 0) { item = component.menu.items.items[idx]; } component.setActiveItem(item) }


Reply With Quote