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

Forums / Developing with Sitefinity / RadTreeView - Having a expand collapse node without any page

RadTreeView - Having a expand collapse node without any page

7 posts, 1 answered
  1. David
    David avatar
    5 posts
    Registered:
    28 Mar 2013
    06 May 2013
    Link to this post
    I just wanted to create a left navigation of below structure.

    Head 1        [Clicking head1 should expand and show its child. Head1 will not have any page]
    > child 1      [actual page]
    > child 2      [actual page]
    Head 2        [Similar to head1]
    > child 1      [actual page]
    > child 2      [actual page]

    I tried to use sitefinity's Navigation control, selected RadTreeView for the template.

    Can I achieve something  similar to the one present in http://demos.telerik.com/aspnet-ajax/menu/examples/megadropdown/defaultcs.aspx.
  2. David
    David avatar
    5 posts
    Registered:
    28 Mar 2013
    08 May 2013
    Link to this post
    I found the setting that caused group page, to redirect to a child page
    X  Group pages redirect to the first subpage
    The above option is turned off and RadtreeView works as expected.

    Now the problem is, when user clicks on the Group page in the Navigation, it gets highlighted. Class name ".rtSelected" is added to every node I click.

    Can this highlighting be stopped and I want to retain the selection to be on the actual page that is shown in the browser.
  3. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    09 May 2013
    Link to this post
    Hello David,

     I tested the navigation behavior and if you have a group page with child pages, and your navigation is configured to "Group pages redirect to the first subpage", the rtSelected class is added to the child node, which is opened when you go to the group page. Wasn't that what you want to achieve?

    Kind regards,
    Jen Peleva
    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
  4. David
    David avatar
    5 posts
    Registered:
    28 Mar 2013
    09 May 2013 in reply to Jen Peleva
    Link to this post
    Hi Jen,
    I didn't want the group page to redirect me to first child page, as I have external links, redirecting page as child page.
    I figured that out :). I unchecked the option in the Navigation widget property. [You can see my 2nd reply]

    Now, I dont want group page to have "rtSelected" class, when I click on it.
    I want "rtSelected" to applied to just child page/actual pages.
     i.e., the selection/Highlight should be retained on page that is currently displayed.

    Please check the leftside naviagtion control in this link for the behaviour that I expect
    http://demos.telerik.com/aspnet-ajax/menu/examples/megadropdown/defaultcs.aspx
  5. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    10 May 2013
    Link to this post
    Hello David,

    Actually, what has to be done is to remove the rtsSelected class with javaScript, once it is set (because it gets set always). Following the demo you showed me, I came up with this sample. Create an ascx file in your project, which will be a custom template for your RadTreeView navigation. Here's the markup:

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RadTreeViewTemplate.ascx.cs" Inherits="SitefinityWebApp.TemplateMapping.RadTreeViewTemplate" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls.SiteMapNavigations" TagPrefix="sitefinity" %>
    <%@ Register Assembly="SitefinityWebApp" Namespace="SitefinityWebApp.customWidgets" TagPrefix="custom" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
    <sf:ResourceLinks ID="resourcesLinks" runat="server">
        <sf:ResourceFile JavaScriptLibrary="JQuery" />
    </sf:ResourceLinks>
    <script type="text/javascript">
        var cachedSelectedNode;
        function ClientNodeClicked(sender, args) {
            var node = args.get_node(),
            $element = $(node.get_element()),
            $selectedNodeElement;
            if (node.get_nodes().get_count() > 0 && !node.get_expanded())
                node.expand();
            else
                node.collapse();
            if (node.get_nodes().get_count() > 0 && cachedSelectedNode) {
                $element.find('div.rtSelected').removeClass("rtSelected");
                $selectedNodeElement = $(cachedSelectedNode.get_element());
                $selectedNodeElement.find('div').addClass("rtSelected");
            }
        }
     
        function ClientNodeClicking(sender, args) {
            if (!cachedSelectedNode) {
                cachedSelectedNode = sender.get_selectedNode();
            }
        }
    </script>
     
    <sitefinity:SiteMapNavigationTreeView runat="server" ID="RTV" OnClientNodeClicked="ClientNodeClicked" OnClientNodeClicking="ClientNodeClicking" />


     Then enter the relative path to the custom template in the Design settings of the navigation. Now it should work as expected.

    All the best,
    Jen Peleva
    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
    Answered
  6. David
    David avatar
    5 posts
    Registered:
    28 Mar 2013
    10 May 2013 in reply to Jen Peleva
    Link to this post
    Hi Jen,
    The script works marvelously.
    But I expected that there will be some simple property to enable/disable highlight onclick.

    Thanks for your help.

    Regards
    David
  7. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    13 May 2013
    Link to this post
    You're welcome, David! :)

    Greetings,
    Jen Peleva
    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 posts, 1 answered