Hello,
i use the WebDataMenu with a WebHierarchicalDataSource. On a Click of an Menu-Item, i use the Navigate-Url to sent a Query-String to the same page and load different content. But on each Postback, not only the content also the Menu is loaded. So How can i expand the Menu to some level and select a Node in code behind?
thanks,
Patric
Ok, i changed my page so there is a content area and the WebDataMenu. I now catch the 'Item-Click' in codebehind and load with a Ado.Net Datareader some Data and bind it to the content area.
I changed the behavior of the WebDataMenu so it expand automatical on Hover and 'CloseMenuOnClick' = False. But if the page load some new data in the content area, no menu item is selected or expanded.
What is my error??
Hello page,
Thank you for posting in the community.
Your WebDataMenu is most likely being reloaded due to the query string changes themselves (it is interpreting it as an entirely new URL). Using an Application variable however, you can persist the selection by handling the ItemSelected and DataBound events. For instance:
Please let me know if this helps.
Hello Petar,
the event, that i catch is 'Item_Click'. If it fires, i use the
Item.Value
to load my content. This value was saved in the 'Application["Sel_Item"].
I also used the DataBound-Event, but it only fires once (if the page is opened for the first time and no Menu-Item was clicked.
So I used your foreach-loop inside the Item-Click Event, but my hierarchical menu was not expanded.
Any idea?
<ig:WebDataMenu ID="WebDataMenu2" runat="server" DataSourceID="whds_Menue2" CloseMenuOnClick="False" SubMenuClosingDelay="20" StyleSetName="Pear" StyleSetPath="ig_res" BorderStyle="None" ForeColor="#f2edde" CssClass="menueitems" ItemSettings-HoverCssClass="menueitems" ItemSettings-ImageToolTip="menueitems" ItemSettings-SelectedCssClass="menueitems" SubMenuOpeningDelay="5" Font-Names="Arial" onitemclick="wdm_Item_Click" EnableAjaxViewState="True" EnableExpandOnClick="False" ondatabound="wdm_Data_Bound"> <ItemSettings CssClass="menueitems" HoverCssClass="menueitems" ImageToolTip="menueitems" SelectedCssClass="menueitems" /> <groupsettings animationduration="800" offsetx="12" offsety="-2" /> <DataBindings> <ig:DataMenuItemBinding DefaultText=" " TextField="Text" ValueField="ID" ImageUrlField="ImageUrl" NavigateUrlFields="" TargetField="Target" ToolTipField="Text" /> </DataBindings></ig:WebDataMenu>
protected void wdm_Item_Click(object sender, Infragistics.Web.UI.NavigationControls.DataMenuItemEventArgs e) { string sSeite = e.Item.Value; if (int.TryParse(sSeite, out iSeite)) { Application["selectedItem"] = sSeite; // Merke den Menüpunkt! Lade_Daten(); } foreach (DataMenuItem item in WebDataMenu2.Allitems) { if (item.Value == Application["selectedItem"].ToString()) { item.Selected = true; } }
Thank you for your reply.
I am still researching the matter, however it seems that handling item click in this scenario may not be possible due to the navigation occurring when clicking on an item. As for having the menu expanded after postback I am unsure that this behavior is supported by the WebDataMenu (a WebDataTree or WebExplorerBar may be more suited for this task). I will continue my research on this topics and provide you with any information available.
i use the WebDataMenu on the bottom part of a page and the different Menu-Items open from left to right (each time only one part). So i don't think this is possible with the WebExploreBar. May be with the Tree. But the strange behavior is: if i started with the control, i used a item-click to expand the menu and i can catch the click event on client side and the menu stay expanded. (i only used the code behind because a an ado.net dataReader was easier for me to handle; use the value of the clicked menu item, to load the data). Now if i use the default 'expand'-event (mouse hover) the menu close immeditely, if the mouse went out (that's correct but i see no way to let it expanded via code behind).
hope you find some answer soon, because it is for a running project.
Thanks
Hello Patric,
Thank you for your reply and feedback.
I am still working on this matter and will keep you posted of my progress.
Apologies for the delayed response.
I am attaching a sample illustrating how the menu may be opened after a postback to the currently selected item (with the querystring changing). Note, however that submenus would be closed after unhovering the menu (this is due to the control's design).
Please feel free to contact me if I may be of assistance.
Hi Patric,
Please feel free to contact me if I can be of further assistnace.
thanks for your sample, it point me in the right direction. It works part-time, because i use the click event, after the second click the menu don't expand. The solution for me is a client and server side code, that i explained on my other post: http://es.infragistics.com/community/forums/t/71778.aspx
The problem is the caching of some 'Menu-Structure' so the 'item-selected'-collection freezed the sub-menu. You can see my working solution on http://www.sternenweg.net/detailseite.aspx. The item 'sternenweg' shows the problem area. I must rebind the data on the server, to destroy the client cache.
Your code with the 'get_selectedItem() != null' on the client side Init-Event was the key.
Thanks for the help
Hi, I just want to add that I am almost 100% sure that ItemCollapsing client side event is cancelable! Check out all the client events here. On the client side event handler set the cancel property to true:
eventArgs.set_cancel(true)
This way one will prevent submenu from closing!