PDA

View Full Version : [CLOSED] CycleButton setActiveItem



cwolcott
Oct 16, 2014, 5:23 PM
I would like to set the active item for a CycleButton, but all I have is the text for one of the CheckMenuItems in the CycleButton.



<ext:CycleButton ID="CycBtn" runat="server" ClientIdMode="Static" ShowText="true" PrependText="<b>Type: </b>">
<Menu>
<ext:Menu runat="server">
<items>
<ext:CheckMenuItem runat="server" Text="Title" Icon="Cog" />
<ext:CheckMenuItem runat="server" Text="Description" Icon="Cog" />
<ext:CheckMenuItem runat="server" Text="ByPass" Icon="Cog" />
</items>
</ext:Menu>
</Menu>
</ext:CycleButton>


I have the string "Description" and thus would like to perform the following, but how do I find the index of the CheckMenuItem within CycBtn that has a value of "Description".



App.CycBtn.setActiveItem(1, true);


A second related question: What is the best way to reference the value from the first menuitem in the CycleButton. The following works, but it is not pretty.



App.CycBtn.menu.initialConfig.items[0].text;

Daniil
Oct 16, 2014, 6:41 PM
Hi Chris,

1. I can suggest this.

var item = App.CycBtn.menu.child(Ext.String.format("[text={0}]", "Description"))
App.CycBtn.setActiveItem(item);

2. I can suggest this.

App.CycBtn.menu.items.first().text

Well, not pretty still, but more correct, I think. If the text is changed on the fly, it won't appear in the initialConfig.

cwolcott
Oct 17, 2014, 2:33 PM
Please close the thread. Great information, thanks.