Breadcrumb with Treeview

6 posts, 0 answers
  1. Ted
    Ted avatar
    47 posts
    Member since:
    Jan 2008

    Posted 02 Mar 2011 Link to this post

    I need a breadcrumb to list the nodes of the selected node in a treeview.

    so basically I want the same as this demo but with a treeview for the selector instead of another menu.
    http://demos.telerik.com/aspnet-ajax/menu/examples/programming/showpath/defaultcs.aspx?Page=Renewals%20&%20Upgrades
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 07 Mar 2011 Link to this post

    Hi Ted,

    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:
    Copy Code
    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();
            }
        }
    }

    Here is also a simple css class that I used for highlighting the path:
    Copy Code
    .focused  { background-color: Yellow !important; }
     

    Best wishes,
    Kate
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Srujana
    Srujana avatar
    38 posts
    Member since:
    Jan 2011

    Posted 15 Mar 2011 Link to this post

    Hello,

    I am looking for the same, could you please give more info on this, which demo are you talking about?

    Thanks,
    Srujana.
  5. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 16 Mar 2011 Link to this post

    Hello Srujana,

    Please take a look at the first thread (posted by Ted).

    Best wishes,
    Kate
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  6. rajaganapathi
    rajaganapathi avatar
    3 posts
    Member since:
    Jun 2011

    Posted 22 Jun 2011 Link to this post

    Hi 
        Always the,

    RadTreeNode

     

     

    currentNode1 = radTreeView.FindNodeByUrl(Request.Url.PathAndQuery);
        value in currentNode1 returns null. Hence there is no way of populating in the below region.

     

     

     

     

    if (currentNode1 != null)

     

    {

    HighlightPath(currentNode1);

    PageTitleLiteral.Text = currentNode1.Text;

    DataBindBreadCrumbSiteMap(currentNode1);

    }

    Any idea?

  7. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 28 Jun 2011 Link to this post

    Hi rajaganapathi,

    Are you trying to implement the following demo but with the RadTreeView control? Your code behind seems to be correct but, can you please specify what do you set when using NavigateUrl property of the tree nodes in the markup?

    Regards,
    Kate
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017