Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Add a menu item with client-side javascript
posted

The UltraWebTree control gives the ability to add or remove nodes using javascript. 

The UltraWebMenu does not have this functionality.

Are there any current workarounds?

Can the UltraWebMenu control be enhanced in the future to allow adding or removing items?

 

Thanks

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=8079

 

Parents
  • 28407
    posted

    HI Erice,

    There is a work around to your issue.

    you can create a menu with some items that have their Text set to spaces and their Enable property set to false.

    These items will not show up on the menu. You can then changed the Text and the Eanble property of this disable menu item via javascript.

    In the sample i provide the first parent's child item is disabled. when you click the html button this item will appear with the text "hello" 

    Here is the code to do so :

     <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <%@ Register Assembly="Infragistics2.WebUI.UltraWebNavigator.v7.3, Version=7.3.20073.38, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
        Namespace="Infragistics.WebUI.UltraWebNavigator" TagPrefix="ignav" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    <script language="javascript" type="text/javascript">
    // <!CDATA[

    var mid = null
    function Button1_onclick() {
    //debugger;
    var menu =  igmenu_getMenuById(mid);
    var topitems = menu.getItems();
    var subitems = topitems[0].getItems();
    subitems[0].setText("hello");
    subitems[0].setEnabled(true);
    }
    function UltraWebMenu1_InitializeMenu(menuId){
     //Add code to handle your event here.
     mid = menuId;
    }
    // ]]>
    </script>


    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <ignav:UltraWebMenu ID="UltraWebMenu1" runat="server" JavaScriptFilename="" JavaScriptFileNameCommon=""
                LeafItemImageUrl="" ParentItemImageUrl="" StyleSetName="">
                <ItemStyle Cursor="Default" />
                <Images>
                    <SubMenuImage Url="ig_menuTri.gif" />
                </Images>
                <IslandStyle BackColor="LightGray" BorderStyle="Outset" BorderWidth="1px" Cursor="Default">
                </IslandStyle>
                <HoverItemStyle BackColor="DarkBlue" Cursor="Default" ForeColor="White">
                </HoverItemStyle>
                <Levels>
                    <ignav:Level Index="0" />
                    <ignav:Level Index="1" />
                </Levels>
                <DisabledStyle Font-Names="MS Sans Serif" Font-Size="8pt" ForeColor="Gray">
                </DisabledStyle>
                <SeparatorStyle BackgroundImage="ig_menuSep.gif" CssClass="SeparatorClass" CustomRules="background-repeat:repeat-x; " />
                <ExpandEffects ShadowColor="LightGray" />
                <MenuClientSideEvents InitializeMenu="UltraWebMenu1_InitializeMenu" />
                <Items>
                    <ignav:Item Text="Top Item">
                        <Items>
                            <ignav:Item Enabled="False" Text="">
                            </ignav:Item>
                            <ignav:Item Text="Sub Menu Item">
                                <Items>
                                    <ignav:Item Text="Sub Menu Item">
                                    </ignav:Item>
                                </Items>
                            </ignav:Item>
                            <ignav:Item Text="Sub Menu Item">
                            </ignav:Item>
                            <ignav:Item Hidden="True" Text="Sub Menu Item">
                            </ignav:Item>
                        </Items>
                    </ignav:Item>
                    <ignav:Item Text="Top Item">
                        <Items>
                            <ignav:Item Text="Sub Menu Item">
                            </ignav:Item>
                            <ignav:Item Text="Sub Menu Item">
                            </ignav:Item>
                            <ignav:Item Text="Sub Menu Item">
                            </ignav:Item>
                        </Items>
                    </ignav:Item>
                    <ignav:Item Text="Top Item">
                    </ignav:Item>
                    <ignav:Item Text="Top Item">
                    </ignav:Item>
                </Items>
            </ignav:UltraWebMenu>
       
        </div>
            <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
        </form>
    </body>
    </html>

    Here is a help link to the WebMenu CSOM:

    http://help.infragistics.com/Help/NetAdvantage/NET/2007.3/CLR2.0/html/WebMenu_CSOM_Overview.html

     

    I will enter a feature request on your behalf

     

Reply Children