Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Developing with Sitefinity > Panelbar Parent Node

Panelbar Parent Node

  • Anthony Smith avatar

    Posted on Mar 5, 2010 (permalink)

    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

    Reply

  • Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Mar 5, 2010 (permalink)

    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.

    Reply

  • Anthony Smith avatar

    Posted on Mar 12, 2010 (permalink)

    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

    Reply

  • Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Mar 12, 2010 (permalink)

    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.

    Reply

  • Anthony Smith avatar

    Posted on Mar 12, 2010 (permalink)

    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

    Reply

  • Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Mar 12, 2010 (permalink)

    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.

    Reply

  • Anthony Smith avatar

    Posted on Mar 12, 2010 (permalink)

    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

    Reply

  • Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Mar 15, 2010 (permalink)

    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.

    Reply

  • Register for webinar
Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Developing with Sitefinity > Panelbar Parent Node