1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / SiteMapNavigationTreeView and only current node expanded

SiteMapNavigationTreeView and only current node expanded

8 posts, 0 answered
  1. Andre
    Andre avatar
    23 posts
    Registered:
    07 Feb 2008
    09 Feb 2012
    Link to this post
    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
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    13 Feb 2012
    Link to this post

    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
  3. Andre
    Andre avatar
    23 posts
    Registered:
    07 Feb 2008
    14 Feb 2012
    Link to this post
    Hi,

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

    Regards

    Andre
  4. Andre
    Andre avatar
    23 posts
    Registered:
    07 Feb 2008
    14 Feb 2012
    Link to this post
    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?

  5. Andre
    Andre avatar
    23 posts
    Registered:
    07 Feb 2008
    16 Feb 2012
    Link to this post
    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:
    http://www.sitefinity.com/devnet/forums/sitefinity-4-x/bugs-issues/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
  6. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    16 Feb 2012
    Link to this post
    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
  7. Andre
    Andre avatar
    23 posts
    Registered:
    07 Feb 2008
    16 Feb 2012
    Link to this post
    Hello Boyan,

    yes the version is 4.4.2117.

    Thanks

    Andre



  8. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    01 Mar 2012
    Link to this post
    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
8 posts, 0 answered