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

Forums / General Discussions / Panel bar Nav - StartingNodeOffset

Panel bar Nav - StartingNodeOffset

12 posts, 0 answered
  1. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    03 Feb 2008
    Link to this post
    Hi

    I realise if i have a panel bar, and set the StartingNodeOffset to 1, it will display all the subpages in this menu

    however, it only does this for the current page,
    How would i use the panel bar to show all the subpages of a different page

    e.g. if my site structure is:

    Home
    Services
    - -service 1
    -- service 2
    -- service 3
    Contact

    I can have a panel bar on the services page, set the nodeoffset to 1 and it will just display all the services sub pages

    What i want it to do is diplay all the service sub pages but the panel bar has to be on the homepage

    Thanks
  2. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    04 Feb 2008
    Link to this post
    Hello Quade,

    The Site PanelBar that comes in the toolbox is automatically bound to the Sitemap of your project. What this means is that it gets data according to the Sitemap and where you are currently in the hierarchy. Displaying subpages of a page that you are not visiting means that you do not want to bind to the Sitemap, but instead provide static content, one and the same every time. For this purpose, I suggest you use RadPanelBar (as opposed to Site PanelBar) and statically populate it with the required pages. Please let us know if you have any other issues.

    All the best,
    Slavo
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    04 Feb 2008
    Link to this post
    thanks thats great

    ive looked into the rad panel bar but cannot see how to get the required results, can you explain please and point me in the right direction

    thanks
  4. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    07 Feb 2008
    Link to this post
    Hello Quade,

    The thing I'm talking about is illustrated in the following example for RadPanelBar:
    http://www.telerik.com/demos/aspnet/Panelbar/Examples/Programming/DynamicCreation/DefaultCS.aspx

    You can simply populate it in code, by placing the RadPanelbar in a user control and writing the code in the code-behind file. The downside is, if your page hierarchy changes you have to manually apply the changes to the user control. But, since you want a static display of pages, this is the preferred option.


    Sincerely yours,
    Slavo
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    24 Jun 2008
    Link to this post

    THanks

    But is there any way to bind this to the sitemap and specify the starting node?

    i.e. put it on the homepage but have it show the services sub pages.

    I'm sure this is a pretty common thing, i can see a big use for it

     

    I did find something on goondocks that does just this, but i couldn't get this working and the author hasn't replied to my emails

    any advice appreciated

    Thanks

     

  6. Pepi
    Pepi avatar
    981 posts
    Registered:
    28 Oct 2016
    26 Jun 2008
    Link to this post
    Hi Quade,

    Most probably, there is some misunderstanding about the way the StartingNodeOffset property works. Here is a reference to an article that discusses this property.

    Let's say that your project has the following SiteMap structure:

    Home
    Menu1
    --- Page11
    --- Page12
    Menu2
    --- Page21
    --- Page22

    When you are on "Menu1" or its children, the panelbar will be populated with "
    Page11" and "Page12". Respectively, when you go to "Menu2" or its children, the navigation control will show "Page21" and "Page22". But when you are on "Home", the panelbar will not display any items because StartingNodeOffset property is set to 1 and "Home" has no sub pages. Actually, the currently requested page is used as a starting node.

    So, to achieve the required functionality, you can either use a static Panelbar or a Panelbar that is bound to a custom data source. Here is an example of what I mean:

    .ascx
    <%@ Register Assembly="RadPanelbar.Net2" Namespace="Telerik.WebControls" TagPrefix="radP" %> 
     
    <radP:RadPanelbar ID="RadPanelbar1" runat="server" EnableViewState="false"
    </radP:RadPanelbar> 

    .ascx.cs
    protected void Page_Load(object sender, EventArgs e) 
        { 
            foreach (SiteMapNode node in SiteMap.RootNode.GetAllNodes()) 
            { 
                if (node.Title == "Services"
                { 
                    IList<SiteMapNode> list = new List<SiteMapNode>(); 
                    foreach (SiteMapNode node1 in node.ChildNodes) 
                    { 
                        list.Add(node1); 
                    } 
     
                    RadPanelbar1.DataSource = list; 
                    RadPanelbar1.DataBind(); 
                } 
            } 
        } 

    Hope this helps.

    Best wishes,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    25 Nov 2009
    Link to this post
    Hi - Instead of having to create different templates for each level of the site map and setting the StartingNodeOffset differently for each, (parent, child, child, child) I am creating a RadPanelBar control that will:

    Display only the first level children on the parent page
    Display only the first level siblings on the child page
    Display only the same as above for any children of children pages

    Do I put this code inside public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)?

    So basically I have something like this but I don't think it is right... what/where should I be putting hte code?

    CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;  
            if (node != null )  
            {  
                if (node.PageType.e.Item.Level != 0) //not a parent node   
                {  
                    this.StartingNodeOffset = -1;  
                    this.StartFromCurrentNode = true;  
                    this.ShowStartingNode = false;  
                    this.Skin = "";  
                }  
     
                if (e.Item.Level == 0) //is a parent node  
                {  
                    //do something  
                    this.StartingNodeOffset = 0;  
                    this.StartFromCurrentNode = true;  
                    this.ShowStartingNode = false;  
                    this.Skin = "";  
                                      
                }  
            } 

    I have a horizontal navigation bar at the top to diplay the parents by the way.  Only want to display the first level children of the selecteed parent page on each and every page no matter the level of the page you are on.

    Thank you for your help!
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    26 Nov 2009
    Link to this post
    Hi Laura,

    Thank you for using our services.

    You are on the right path. You should bind the RadPanelBar to a SiteMapDatasource first  - you can see example for this in the code for our navigation controls in ~/Sitefinity/UserControls/Navigation35/SitePanelbar.ascx. Then you should subscribe to the ItemDataBound event of the panel bar to add your logic.

    All the best,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    29 Nov 2009
    Link to this post
    As always, thank you for your quick response.

    Can you help me a little further? I want to use the PanelBar in a template, and set it so that the first level children are always shown no mater what level page you are on. So instead of having two templates (one for the parent pages with the startingnodeoffset set to 0 and one for the children pages with the startingnodeoffset  set to -1, I want to do this programatically in the control.

    I created a custom RadPanelBar control with the code from ~/Sitefinity/UserControls/Navigation35/SitePanelbar.ascx.
    But I don't think it is 'reading' this code when it loads the page.
    Should I be doing something in the logc here:?
    [DefaultProperty("StartingNodeOffset")]  
    public partial class Custom_Controls_sitePanelBarNav : System.Web.UI.UserControl, ICacheableObject  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
            if (!Page.IsPostBack)  
            {  
     

    This is what I have so far...

        public void RadPanelbar1_ItemDataBound(object sender, RadPanelBarEventArgs e)  
        {  
     
            
     
            CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;  
            if (node != null )  
            {  
                if (e.Item.Level != 0) //not a parent node   
                {  
                    //do something  
                    this.StartingNodeOffset = -1;  
                    this.StartFromCurrentNode = true;  
                    this.ShowStartingNode = false;  
                    this.Skin = "";  
                     
                }  
     
                if (e.Item.Level == 0) //is a parent node  
                {  
                    //do something  
                    this.StartingNodeOffset = 0;  
                    this.StartFromCurrentNode = true;  
                    this.ShowStartingNode = false;  
                    this.Skin = "";  
               }  
            }  
     
              
              
            if (this.hideUrlForGroupPages)  
            {  
                //CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;  
                if (node != null && node.PageType == CmsPageType.Group)  
                {  
                    e.Item.NavigateUrl = "";  
                }  
            }  
        } 

    Thank you!  
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Nov 2009
    Link to this post
    Hi Laura,

    Try moving the code to OnPreRender method.

    protected override void OnPreRender(EventArgs e)
       {
           base.OnPreRender(e);
           foreach (RadPanelItem item in RadPanelbar1.GetAllItems())
           {
     
               if (item.Level != 0)
               {            
                   this.StartingNodeOffset = -1;
                   this.StartFromCurrentNode = true;
                   this.ShowStartingNode = false;
                   this.Skin = "";
               }
               if (item.Level == 0)
               {
                   this.StartingNodeOffset = 0;
                   this.StartFromCurrentNode = true;
                   this.ShowStartingNode = false;
                   this.Skin = "";
               }
           }
       }


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  11. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    29 Nov 2009
    Link to this post
    Thank you Ivan, I am almost there..

    If I put the sitefinity PanelBarNav on each of the pages and set the starting node that way, it works. But it doesn't seem to work programatically if placed on the template.
    If I have
    Parent
        Child
            Child Child

    and I want to show on the left hand side, the link to Child only on all three pages, I can make it happen by placing the control on each page and setting the starting node to 0 for the Parent, -1 for the Child and -2 for the Child Child.  The link on the left hand side always shows the link to the Child.
    However if I do this in code, it doesn't render!

    I also set wthin the interface of the control the following:

    StartFromCurrentNode = true
    ShowStartingNode = false
    M
    axDataBindDepth = 1
    EmbeddedBaseStyleSheet = false

    On my Child page I get it's child page and on it's child page, I get nothing.

    I am sure it is something simple I am missing. Thank you for all of your help!

     

     

        protected override void OnPreRender(EventArgs e)  
        {  
            base.OnPreRender(e);  
            foreach (RadPanelItem item in RadPanelbar1.GetAllItems())  
            {  
                  
                if (item.Level == 0)  
                {  
                    this.StartingNodeOffset = 0;  
       
                }  
     
                if (item.Level == 1)  
                {  
                    this.StartingNodeOffset = -1;  
     
                }  
     
                if (item.Level == 2)  
                {  
                    this.StartingNodeOffset = -2;  
     
                }  
                  
            }  
        } 

     

     



  12. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    30 Nov 2009
    Link to this post
    Hello Laura,

    I think that you are not getting anything beyond that level because you have MaxDataBindDepth = 1 set in your control. As for your previos posts when you said that you are not getting the code executed on the ItemDataBound event - how did you subscribe to the event? If it was in the markup of the control, did you have
    <%@ Control Language="C#" AutoEventWireup="true"
     
    for your control?
     
    Regards,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
12 posts, 0 answered