breadcrumbs for treeview

2 posts, 0 answers
  1. Roukaya
    Roukaya avatar
    17 posts
    Member since:
    Aug 2012

    Posted 25 Jun 2012 Link to this post

    Hello  all ,

    how can i create a breadcrumbs for RadTreeView (using telerik asp.net ajax) ???

    thanks in advance
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Jun 2012 Link to this post

    Hi Roukaya,

    You can achieve this simply by replacing the Menu from the demo with a RadTreeView. Then you will need to change the code behind as follows:
    C#:
    using System;
    using System.Collections.Generic;
    using Telerik.Web.UI;
      
    namespace Telerik.Web.Examples.Menu.ShowPath
    {
        public partial class DefaultCS : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                  
                RadTreeView1.ExpandAllNodes();
      
                RadTreeNode currentNode = RadTreeView1.FindNodeByUrl(Request.Url.PathAndQuery);
                if (currentNode != null)
                {
                    //Select the current item and his parents
                    HighlightPath(currentNode);
                     
                    PageTitleLiteral.Text = currentNode.Text;
                    //Populate the breadcrumb
                    DataBindBreadCrumbSiteMap(currentNode);
                }
      
            }
      
            public void HighlightPath(RadTreeNode currentNode)
            {
                while (currentNode != null)
                {
                    if (!currentNode.CssClass.Contains("focused"))
                    {
                        currentNode.CssClass = "focused";
                    }
                    currentNode = currentNode.Owner as RadTreeNode;
      
                }
      
            }
      
            private void DataBindBreadCrumbSiteMap(RadTreeNode currentNode)
            {
                List<RadTreeNode> breadCrumbPath = new List<RadTreeNode>();
                while (currentNode != null)
                {
                    breadCrumbPath.Insert(0, currentNode);
                    currentNode = currentNode.Owner as RadTreeNode;
                }
                BreadCrumbSiteMap.DataSource = breadCrumbPath;
                BreadCrumbSiteMap.DataBind();
            }
        }
    }
    CSS:
    .focused
    {
     background-color: Yellow !important;
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top