Apr 28, 2013, 5:10 PM
[CLOSED] MenuPanel dymanic items are not selected
Hi!
I'm using MenuPanel creating items dynamically. The items are created properly and normally respond to the Click event. The problem is that the clicked item does not get selected in MenuPanel. When items are defined via markup selection functions normally as an example:
What setting should be done to enable this feature?
Below is an example of the application. In my application I have several tabs and when one of them is activated perform dynamic loading MenuPanel.
Ermanni.
I'm using MenuPanel creating items dynamically. The items are created properly and normally respond to the Click event. The problem is that the clicked item does not get selected in MenuPanel. When items are defined via markup selection functions normally as an example:
What setting should be done to enable this feature?
Below is an example of the application. In my application I have several tabs and when one of them is activated perform dynamic loading MenuPanel.
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
}
[DirectMethod]
public void UpdateMenu()
{
MenuPanel1.Menu.Items.Clear();
var aux = new Random();
var max = aux.Next(1, 15);
for (int i = 0; i < max; i++)
{
MenuPanel1.Menu.Items.Add(new Ext.Net.MenuItem
{
ID = "menuItem" + i.ToString(),
Text = "Dynamic item " + i.ToString()
});
}
MenuPanel1.Menu.ReRender();
MenuPanel1.SetSelectedIndex(0);
}
</script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
var menuItemClick = function (menu, item) {
App.PnlCenter.body.update(Ext.String.format("Clicked: {0}", item.text)).highlight();
};
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Window ID="Window1"
runat="server"
Title="MenuPanel"
Closable="false"
Width="600"
Height="370"
Layout="BorderLayout">
<Items>
<ext:TabPanel runat="server"
ID="tabManutencao"
Region="Center"
Border="False">
<Items>
<ext:Panel ID="TabPanel1"
runat="server"
Title="Tab1"
Layout="BorderLayout"
Border="false"
BodyPadding="0"
Flex="1">
<Items>
<ext:TextField ID="txtSample"
FieldLabel="Informe um valor:"></ext:TextField>
</Items>
</ext:Panel>
<ext:Panel ID="TabPanel2"
runat="server"
Title="Tab2"
Layout="BorderLayout"
Border="false"
BodyPadding="0"
Flex="1">
<Listeners>
<Activate Handler="#{DirectMethods}.UpdateMenu();"></Activate>
</Listeners>
<Items>
<ext:Panel ID="Panel1"
runat="server"
Width="350"
Layout="Accordion"
Split="true"
Region="West"
Margins="5 0 5 5"
Border="false">
<Items>
<ext:MenuPanel ID="MenuPanel1"
runat="server"
Title="MenuPanel with Selection Saving"
Icon="ArrowSwitch">
<Menu ID="Menu1" runat="server">
<Items>
</Items>
<Listeners>
<Click Fn="menuItemClick" />
</Listeners>
</Menu>
</ext:MenuPanel>
</Items>
</ext:Panel>
<ext:Panel
ID="PnlCenter"
runat="server"
Title="Selected Item"
BodyPadding="5"
Region="Center"
Margins="5 5 5 0"
/>
</Items>
</ext:Panel>
</Items>
</ext:TabPanel>
</Items>
</ext:Window>
</form>
</body>
</html>
Thanks!Ermanni.
Last edited by Daniil; May 03, 2013 at 3:58 AM.
Reason: [CLOSED]