More in this section

Forums / Developing with Sitefinity / Custom databinding with the panelbar

Custom databinding with the panelbar

4 posts, 0 answered
  1. rmp
    rmp avatar
    13 posts
    Registered:
    26 Jun 2007
    27 Jul 2007
    Link to this post
    Hi,

    We have a situation where we'd like to have a navigation menu on the top, as well as a "sub" menu along the left side. I understand that in sitefinity there is only one sitemap, but I would like to databind a sitepanelbar to PART of the sitemap (i.e. treat one particular branch of the tree as a sitemap and bind to that).

    It seems to me that the best way to do this is during databinding, but that seems to happen behind the scenes. I don't really like the idea of going through the databound tree afterwards and removing all the items I don't want.

    Can anyone suggest a nice way of doing this?

    Thanks!
    Mark
  2. Bob
    Bob avatar
    330 posts
    Registered:
    30 Dec 2016
    28 Jul 2007
    Link to this post
    Hi Mark,

    Since you haven’t indicated the version of Sitefinity you are using I assume version 3.0 SP2.

    We have provided with SP2 a few navigational user controls located in ~/Sitefinity/UserControls folder. You can modify these controls to achieve this. I suggest that you copy the control you want to modify and give it a different name so you don’t loose your changes when you upgrade your project to a higher version.

    All you need to do is to specify a StaringNode for the SiteMapDataSouce control. SitemapDataSource1.StartingNodeUrl = "~/BranchRoot.aspx";

    Greetings,
    Bob
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. rmp
    rmp avatar
    13 posts
    Registered:
    26 Jun 2007
    30 Jul 2007
    Link to this post
    Thanks Bob, that is perfect. 

    Now I have a couple issues with customizing the sitemenu:

    1. When trying to customize the style of one of the menu items, the class attribute that is written out to html is overriding the style that is set here in code:

                    // here you can set the style for the top-level item  
                    item.ForeColor = Color.Red;

    So this code has no effect.

    2. Is there a way to prevent a drop down menu from appearing for one particular top-level menu item that has navigable child items?

    Any guidance you can give is greatly appreciated.
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    31 Jul 2007
    Link to this post
    Hi Mark,

    1. You should set the color of the item in the method handling OnItemDataBound event. I try the following piece of code and it works according to expectation:

    // gets the top-level item and sets its color to Red

    RadMenuItem item = e.Item;

    if (item != null && item.Level == 0)

        item.ForeColor = Color.Red;

    If you continue having the same problem, please send the code that customizes the style of the menu item to specify what’s wrong. Also you could find more detailed information for the RadMenu control in online documentation http://www.telerik.com/help/aspnet/menu/ .

    2. As for your second question, please have a look at this thread http://sitefinity.com/support/forums/support-forum-thread/b1043S-mkkeh.aspx. I think the last suggestion with OnItemDataBound will help you.

    Don’t hesitate to contact us if you come up with more questions.

    Sincerely yours,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
4 posts, 0 answered