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

Forums / Developing with Sitefinity / Panelbar Parent Node

Panelbar Parent Node

8 posts, 0 answered
  1. Anthony Smith
    Anthony Smith avatar
    34 posts
    Registered:
    08 Dec 2009
    05 Mar 2010
    Link to this post
    Hi,

    I've got a panel bar on my site that I've modified to make sure the expand animation and collapse animations don't happen until the user has gone to a new page.

    The structure of this panel is as follows:
    - About
        - The team
        - History
        - contact us

    I've added the following code to the sitepanelbar.ascx:

    <script type="text/javascript">  
    function OnClientItemClicking(sender, eventArgs)  
    {  
       var item = eventArgs.get_item();  
       var navigateUrl = item.get_navigateUrl();  
       if (navigateUrl && navigateUrl != "#")  
       {  
          var item = eventArgs.get_item();    
            if(item.get_expanded() == true)  
      
          {  
             eventArgs.set_cancel(true);  
          }  
          else  
          {  
             eventArgs.set_cancel(false);  
          }  
       }  
    }  
    </script>  
      
      
       
       
        
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false"/>  
    <telerik:RadPanelBar ID="RadPanelbar1" runat="server" DataSourceID="SiteMapDataSource1" OnItemDataBound="RadPanelbar1_ItemDataBound" EnableViewState="false" OnClientItemClicking="OnClientItemClicking" >  
        
    </telerik:RadPanelBar>  

    Once this is added the I can no longer click and navigate to the parent node (i.e. about). Can you tell me where I am going wrong?

    Thanks,

    Anthony

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    05 Mar 2010
    Link to this post
    Hello Anthony Smith,

    Thank you for using our services.

    The issue with the JavaScript function is that it cancels the navigation to the parent item too. You should check if the Item you wish to navigate to is the parent item of the currently selected item. Sample bellow:

    <script type="text/javascript"
    function OnClientItemClicking(sender, eventArgs) {
        var panelBar = $find("<%= RadPanelbar1.ClientID %>");
        var item = eventArgs.get_item(); 
        var navigateUrl = item.get_navigateUrl(); 
        if (navigateUrl && navigateUrl != "#"
        
            var item = eventArgs.get_item();
            if (item.get_expanded() == true && item != panelBar.get_selectedItem().get_parent()) {
                eventArgs.set_cancel(true);
            }
            else {
                eventArgs.set_cancel(false);
            
       
    </script>

    All the best,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Anthony Smith
    Anthony Smith avatar
    34 posts
    Registered:
    08 Dec 2009
    12 Mar 2010
    Link to this post
    Hi Radoslav,

    Many thanks for your input.

    I've got some pages that are quite deap i.e.:

    -. About
          - Services
                Service 1
                        Service 1a
                        Service 1b

    The problem I'm having with the snippet provided is that if say I'm in section Service 1a, and try to go to services it won't let me, I get the same problem if I'm in Service 1a and try to go to About.

    Do you have any clues on how I achieve this without loosing the functionality outlined in my previous post?

    Thanks,

    Anthony
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    12 Mar 2010
    Link to this post
    Hello Anthony Smith,

    You can try canceling the navigtation to the selected item only. To get the selected item use panelBar.get_selectedItem().

    All the best,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Anthony Smith
    Anthony Smith avatar
    34 posts
    Registered:
    08 Dec 2009
    12 Mar 2010
    Link to this post
    Hi Radoslav,

    I'm trying to get this to work, but when I click on the root it is coming up with a javascript error.

    Do you have any ideas what I'm doing wrong?

    Thanks,

    Anthony
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    12 Mar 2010
    Link to this post
    Hi Anthony Smith,

    What is the javascript error?

    All the best,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Anthony Smith
    Anthony Smith avatar
    34 posts
    Registered:
    08 Dec 2009
    12 Mar 2010
    Link to this post
    Hi Radoslav,

    I'm no longer getting the JS error - but its still not allowing me to go to the Expanded Level 1 and Level 2 pages if I'm on an expanded Level 4 page.

    <script type="text/javascript">  
    function OnClientItemClicking(sender, eventArgs) {
        var panelBar = $find("<%= RadPanelbar1.ClientID %>");
        var item = eventArgs.get_item();  
        var navigateUrl = item.get_navigateUrl();  
        if (navigateUrl && navigateUrl != "#")  
        {  
            var item = eventArgs.get_item();
            if (item.get_expanded() == true && item != panelBar.get_selectedItem().get_selectedItem()) {
                eventArgs.set_cancel(true);
            }
            else {
                eventArgs.set_cancel(false);
            }  
       }  
    }  
    </script>


    Thanks,

    Anthony
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    15 Mar 2010
    Link to this post
    Hi Anthony Smith,

    Can you try something like this:

    <script type="text/javascript">
        function OnClientItemClicking(sender, eventArgs) {
            var panelBar = $find("<%= RadPanelbar1.ClientID %>");
            var item = eventArgs.get_item();
            var navigateUrl = item.get_navigateUrl();
            if (navigateUrl && navigateUrl != "#") {
                var item = eventArgs.get_item();
                if (item.get_expanded() == true && item == panelBar.get_selectedItem().get_expandedItem()) {
                    eventArgs.set_cancel(true);
                }
                else {
                    eventArgs.set_cancel(false);
                }
            }
        
    </script>

    All the best,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
8 posts, 0 answered