This is a migrated thread and some comments may be shown as answers.

Breadcrumb with Treeview

5 Answers 172 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Ted
Top achievements
Rank 1
Ted asked on 02 Mar 2011, 07:27 PM
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

5 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 07 Mar 2011, 04:00 PM
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!
0
Srujana
Top achievements
Rank 1
answered on 15 Mar 2011, 10:22 PM
Hello,

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

Thanks,
Srujana.
0
Kate
Telerik team
answered on 16 Mar 2011, 10:07 AM
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!
0
rajaganapathi
Top achievements
Rank 1
answered on 22 Jun 2011, 10:36 AM
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?

0
Kate
Telerik team
answered on 28 Jun 2011, 12:01 PM
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.

Tags
Menu
Asked by
Ted
Top achievements
Rank 1
Answers by
Kate
Telerik team
Srujana
Top achievements
Rank 1
rajaganapathi
Top achievements
Rank 1
Share this question
or