SiteMapNavigationTreeView and only current node expanded
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
Hi,
thanks for the files I'll try it than with the nativ control.
Regards
Andre
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?
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
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
Hello Boyan,
yes the version is 4.4.2117.
Thanks
Andre
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