SiteMapNavigationTreeView and only current node expanded

Posted by Community Admin on 04-Aug-2018 13:05

SiteMapNavigationTreeView and only current node expanded

All Replies

Posted by Community Admin on 09-Feb-2012 00:00

Hi,

I like the SiteMapNavigationTreeView to have just the current node, it parent and subnodes expanded.
So I made a custom control like this but it has no effect:

<%@ Control Language="C#" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls.SiteMapNavigations" TagPrefix="navcontrols" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register TagPrefix="sf" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.PublicControls"%>
    <sf:JavaScriptEmbedControl runat="server" ID="jQyeryLink" ScriptEmbedPosition="Head" ScriptType="jQuery"></sf:JavaScriptEmbedControl>
<script runat="server" type="text/C#">
    private string currentNodeUrl;
    protected void Page_Load()
   
        TreeNavigation.NodeDataBound += new RadTreeViewEventHandler(TreeNavigation_NodeDataBound);
        SiteMapNode currentNode = Telerik.Sitefinity.Web.SiteMapBase.GetCurrentProvider().CurrentNode;
        currentNodeUrl = currentNode.Url;
   
 
    void TreeNavigation_NodeDataBound(object sender, RadTreeNodeEventArgs e)
   
 
        if (e.Node.NavigateUrl.Equals(currentNodeUrl))
       
            e.Node.Selected = true;
            e.Node.ExpandParentNodes();
            e.Node.Expanded = true;
            e.Node.ExpandChildNodes();
       
        else
       
            e.Node.Selected = false;
            e.Node.CollapseParentNodes();
            e.Node.Expanded = false;
            e.Node.CollapseChildNodes();
       
   
</script>
<div id="leftMenu">
<navcontrols:SiteMapNavigationTreeView ID="TreeNavigation" runat="server">
</navcontrols:SiteMapNavigationTreeView></div>

What I'm doing wrong here?

Thanks

Andre

Posted by Community Admin on 13-Feb-2012 00:00


Hi,

You can easily achieve such functionality(and even extend it) by wrapping our SitefinitySiteMapDataSource control (the one that we're using for binding our navigation controls) and a RadTreeView inside a user control. I've prepared a sample user control for you (attached to this reply, along with a short video demonstrating the control functionality), which should duplicate the desired functionality. If there's anything else we can help you with, or you need any additional information regarding the user control, please do not hesitate to get back to us.


All the best,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 14-Feb-2012 00:00

Hi,

thanks for the files I'll try it than with the nativ control.

Regards

Andre

Posted by Community Admin on 14-Feb-2012 00:00

I used the control you attached as custom template for a Navigation.
This seems to work at all but there're two problems.
The first one is that currNode is ever null as I think myUrlName is not really an attribute?
var currentNode = treeView.findNodeByAttribute("myUrlName", location);

Also in the video is a function called ExpandParent() - what is the JavaScript code for this?

Posted by Community Admin on 16-Feb-2012 00:00

Hi,

I'm sorry I need some more help to make it work ...
When I use the sample as an own Widget I get a JScript error like descripted here:
www.sitefinity.com/.../can-t-make-sitefinity-working-anymore-becuase-of-jscript-error.aspx

I think because ot DataSourceID="SitefinitySiteMapDS" - SitefinitySiteMapDS is null?

But I can't understand the handling / creating of the DataSource in the video you point to  ....

Regards

Andre

Posted by Community Admin on 16-Feb-2012 00:00

Hello Andre,

Can you please let us know if you're using the same Sitefinity version (4.4.2117) as specified for this ticket or an older version,as it's possible that the control is not found since we've introduced it in versions 4.2 and on. Looking forwards to your reply.

Kind regards,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 16-Feb-2012 00:00

Hello Boyan,

yes the version is 4.4.2117.

Thanks

Andre



Posted by Community Admin on 01-Mar-2012 00:00

Hello Andre,

Thank you for getting back to us, please find attached a complete Sitefinity 4.4.2117 project (database backup is located in the project folder, backend login: u: admin p: password) and a revised version of the Navigation template (located under ~/ControlTemplates/TreeViewCustom). In the project we've added 10 sample pages using the same template and a navigation control on that template using the customized TreeView template. Please take a look at it and let us know if you need any additional information, we'll be glad to help.

All the best,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
[View:/cfs-file/__key/communityserver-discussions-components-files/296/339925_5F00_AndreSampleTreeView_2D00_part1.rar:320:240]
[View:/cfs-file/__key/communityserver-discussions-components-files/296/339926_5F00_AndreSampleTreeView_2D00_part2.rar:320:240]

This thread is closed