Unplanned
Last Updated: 08 Jan 2021 12:42 by ADMIN
Lee Nessling
Created on: 10 May 2017 17:02
Category: Navigation
Type: Feature Request
0
RadNavigation does not highlight menu when using SiteMapDatasource as the RadMenu does
 For a Radmenu, when the current URL matches the site node url in the SiteMapDataSource, the corresponding menu items are highlighted (marked as selected).  This allows the user to see on the menu, where they are in the menu.

RadNavigation does not support this functionality.

 I've added the functionality myself, however it's not elegant as the NavigationNode does not contain it's parent value.   

Here is how I resolved it.


     private void RadNavigation1_NodeDataBound(object sender, Telerik.Web.UI.NavigationNodeEventArguments e)
        {
  System.Web.SiteMapNode node = ((System.Web.SiteMapNode)e.Node.DataItem);
            e.Node.Attributes.Add("Key", node.Key);

            if (e.Node.NavigateUrl == Page.Request.CurrentExecutionFilePath.ToString())
            {
                HighLightMenu(node);
            }
        }

        void HighLightMenu(System.Web.SiteMapNode node)
        {
            List<NavigationNode> nodes = (List<NavigationNode>)RadNavigation1.GetAllNodes();

            // find navigation node based on site node
            Telerik.Web.UI.NavigationNode navNode = nodes.Find(n => n.Attributes["Key"] != null && n.Attributes["Key"] == node.Key);

            //  Control ctrl = RadNavigation1.FindControl(navNode.ID);
            if (navNode != null)
                navNode.Selected = true;

            if (node.ParentNode != null)
                HighLightMenu(node.ParentNode);
        }
0 comments