Mega Drop Down issue

2 posts, 0 answers
  1. Ram
    Ram avatar
    1 posts
    Member since:
    Nov 2011

    Posted 10 Feb 2012 Link to this post

    Hi,

    Am doing mega drop down menu, where the menu items and sub items are driven from XML file.Actually my wish is drop down should not appear if no sub items are present under a menu item.But in this case am getting an empty drop down.Please let me know how to get out of this.

    Code snippet is as folows and the following attachment is my xml file.


            protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                RadMenu1.LoadContentFile("menu3.xml");
                RadMenu1.DataBind();


            }  
        }

    protected void RadMenu1_DataBound(object sender, EventArgs e)
        {
            RadMenu menu = (RadMenu)sender;
            menu.Width = 880;
            menu.Height = 35;
            foreach (RadMenuItem item in menu.Items)
            {
                RadSiteMap sm = new RadSiteMap();
                PopulateSiteMap(sm, null, item);   

                //sitemap settings to have the menu items appear in columns

                SiteMapLevelSetting rootLevelSetting = new SiteMapLevelSetting(0);
                rootLevelSetting.ListLayout.RepeatColumns = 1;
                rootLevelSetting.ListLayout.RepeatDirection = SiteMapRepeatDirection.Horizontal;
                sm.LevelSettings.Add(rootLevelSetting);
                item.Items.Clear();
                RadMenuItem childItem = new RadMenuItem();


                childItem.Width = 880;
                Panel catWrapper = new Panel();
                catWrapper.CssClass = "Wrapper";
                catWrapper.Width = Unit.Pixel(870);
                catWrapper.Controls.Add(sm);

                childItem.Controls.Add(catWrapper);
                item.Items.Add(childItem);
            }
        }

     private static void PopulateSiteMap(RadSiteMap sm, RadSiteMapNode node, RadMenuItem item)
        {
            if (node == null)
            {
                foreach (RadMenuItem child in item.Items)
                {
                    node = new RadSiteMapNode(child.Text, child.NavigateUrl);             
                    sm.Nodes.Add(node);
                    if (child.Items.Count > 0)
                    {
                        PopulateSiteMap(sm, node, child);
                    }
                }
            }
            else
            {
                foreach (RadMenuItem child in item.Items)
                {              
                    node.Nodes.Add(new RadSiteMapNode(child.Text, child.NavigateUrl));
                    if (child.Items.Count > 0)
                    {
                        PopulateSiteMap(sm, node, child);
                    }
                }
            }       
        }  

    Thanks & Regards
    Mohanram Poola
  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 14 Feb 2012 Link to this post

    Hello Mohanram,

    Please, see this kb article - http://www.telerik.com/support/kb/aspnet-ajax/menu/mega-drop-down-menu-bind-to-xml-datasource.aspx.


    Regards,
    Peter
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top