Apr 07, 2014, 5:46 PM
[FIXED] [#464] [2.5.3] Refreshing Menu items doesn't work
I have a Menu control in the .aspx markup as follow:
It seems that this line: {this.menu.getComponent(this.selectedIndex).deacti vate();} causes the problem cause the "selectedIndex=1" and when only one item exist the this.menu.getComponent(this.selectedIndex) returns undefined. Can you tell me how to solve that using the direct method? Ok, all existed items are being removed and new are added but I could't figure out how to solve this one.
Kind regards
<Menu ID="mnuUserData" runat="server">
<Items>
</Items>
<Listeners>
<Click Fn="editUserData" />
</Listeners>
</Menu>
It's menu items are added during the page load event. So far so good. When a click event occurs on some other menu items in the page, the "updateMnuUserData" function is invoked. What I want is to remove all existed items and load new ones with a direct method. So the updateMnuUserData is something like this. var mnuUserData = Ext.getCmp('mnuUserData ');
mnuUserData .items.each(function (item) {
mnuUserData .remove(item);
});
App.direct.LoadUserData('someTextHere');
And the LoadUserData direct method is something like this. Ext.Net.Menu userMenu = X.GetCmp<Ext.Net.Menu>("mnuUserData");
foreach (Link link in category.Links)
{
Ext.Net.MenuItem newMnuItem = new Ext.Net.MenuItem
{
Text = link.Url,
Icon = Icon.PageWorld
};
userMenu.Items.Add(newMnuItem);
newMnuItem.Render();
}
This code seems to work fine, but not always. First of all It ALWAYS removes existed items and add the respective ones. The scenario where it NEVER works is when I add only one Item. When I do this, clicking on that item does not activate the button. I get an error "Cannot call method 'deactivate' of undefined", on the client size.if(item){this.clearSelection();this.selectedIndex=this.menu.items.indexOf(item);this.getSelIndexField().setValue(this.selectedIndex);item.activate();}}},clearSelection:function(){if(this.selectedIndex>-1){this.menu.getComponent(this.selectedIndex).deactivate();}
It seems that this line: {this.menu.getComponent(this.selectedIndex).deacti vate();} causes the problem cause the "selectedIndex=1" and when only one item exist the this.menu.getComponent(this.selectedIndex) returns undefined. Can you tell me how to solve that using the direct method? Ok, all existed items are being removed and new are added but I could't figure out how to solve this one.
Kind regards
Last edited by Daniil; Sep 29, 2014 at 2:59 PM.
Reason: [FIXED]