How can I hide or show menu items from Client side in ultrawebmenu?
There's no built in way to do this through the WebMenu's CSOM, but you may want to try a couple of things. Using the CSOM you can get direct access to any Item's HTML Element. Using that element you can set the style.display="none". A word of caution, this isn't something that the menu was designed to do, so I can't guarantee it will come without side effects.
The other way I can think of to acheive this functionality would be to leverage the partial rendering capabilities of a WebAsync or UpdatePanel, and make your necessary adjustments on the server-side. The only drawback for this option is that it's entirely possible that the user will open a menu prior to the re-rendering, and hence see stale items.
Hope this helps,
-Tony
Tony,
Thanks for the info. Can this be entered as an enhancement request. The menu items have an enabled property, please add a visible property that can be manipulated in client-side javascript.
Thanks
Looks good, I'm glad it works for you. Just wanted to let you know that the "Item" type is located in the Infragistics.WebUI.UltraWebNavigator namespace, so you can use it if you import the namespace. For example:
// C#
using Infragistics.WebUI.UltraWebNavigator;
//VB.NET
imports Infragistics.WebUI.UltraWebNavigator;
Rumen Stankov"] if (!Page.IsPostBack) { Item item = UltraWebMenu1.Find("Child 1", false); item.Hidden = true; }
if (!Page.IsPostBack) { Item item = UltraWebMenu1.Find("Child 1", false); item.Hidden = true;
}
Looks good, except that there is no object type "Item". There is a "MenuItem" type, which I thought you meant but it does not work with the UltraWebMenu Find method. However, I have discovered that merely using
UltraWebMenu1.Find("Child 1", false).Hidden = true;
works just fine!
Yes, absoltely, this is perfectly possible. Imagine that you start with the following menu definition in your ASPX:
<Items> <ignav:Item Text="Top Item"> <Items> <ignav:Item Text="Sub Menu Item"> </ignav:Item> </Items> </ignav:Item> <ignav:Item Text="Top Item"> <Items> <ignav:Item Text="Child 1"> </ignav:Item> </Items> </ignav:Item> <ignav:Item Text="Top Item"> <Items> <ignav:Item Text="Sub Menu Item"> </ignav:Item> </Items> </ignav:Item> </Items>
Then, you can easily hide the item with text "Child 1" in Page_Load using the following code:
I too want to be able to make menu items visible or invisible depending of user role membership. True there is no visible property, but there is a "Hidden" property which sounds like it does the same thing. Can this "Hidden" property be set to "true" by default (on the .aspx page) and set to "false" in the code behind Page_Load event? If so, could you please provide some sample .VB code showing how to address the individual items (there is no "id=" property for each item).
It can absolutely be entered as a feature request - there's a page on our site where you can enter any feature requests you think of :
http://devcenter.infragistics.com/Protected/RequestFeature.aspx