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

Forums / Designing with Sitefinity / panelbar - assigning a new class to selected Group ?

panelbar - assigning a new class to selected Group ?

8 posts, 0 answered
  1. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    17 Jun 2009
    Link to this post
    the panel bar renders the following HTML
    However, i need to ammend it to write out a class:

    <div class="panelbar">
     <ul>
       <li class="item first">
       <li class="item"> (Need to have a class on here called "ItemSelected")
          <a class="selected">
          <ul class="group level1">


    How would i do this?
    Thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    19 Jun 2009
    Link to this post
    Hello Quade,

    You can get the PanelBar item on ItemDataBound event and add SelectedCssClass to it

    Sample code:

    e.Item.SelectedCssClass = "MyCssClass"

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    19 Jun 2009
    Link to this post
    Thanks i've tried that but it doesn't get added to the LI,
     instead it gets added to the A


    so:

    <div class="panelbar">
     <ul>
       <li class="item first">
       <li class="item">
          <a class="selected MyCssClass">
          <ul class="group level1">


    its needs to be:

    <div class="panelbar">
     <ul>
       <li class="item first">
       <li class="item MyCssClass">
          <a class="selected">
          <ul class="group level1">


    Any other ideas?


    the code i used was:

    public void RadPanelbar1_ItemDataBound(object sender, RadPanelbarEventArgs e)
        {
            if (this.hideUrlForGroupPages)
            {
                CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;
                if (node != null && node.CmsPage.PageType == CmsPageType.Group)
                {
                    e.Item.NavigateUrl = "";
                }
            }

            //custom code
            e.Item.SelectedCssClass = "MyCssClass";
            //end custom code
        }

  4. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    24 Jun 2009
    Link to this post
    any updates on a solution to this as i've got a deadline i need to reach asap
    thanks
  5. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    25 Jun 2009
    Link to this post
    Hi Quade,

    I am giving you a reference to all Css related properties of panelbar items that could be changed. If these do not suit your needs, there are only two things you could do:

    1. Incorporate your rules with the default classes
    2. Create a control adapter.

    Unfortunately these are the only suggestions I could give you so far.

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    25 Jun 2009
    Link to this post
    thanks

    i belieive i have found a solution now

    however, i would like to be to do the following on the all root level menu items

    If rootitem has children
      CSSclass= "haschildren"
    else
      CSSclass= "doesnthavechildren"


    how can i acheive this?
  7. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    26 Jun 2009
    Link to this post
    solved:


    put this onload:


    foreach

     

    (RadPanelItem item in RadPanelbar1.Items)

     

    {

     

    if (item.Items.Count > 0)

     

    {

    item.SelectedCssClass =

    "selectedHasChildren";

     

    }

     

    else

     

    {

    item.SelectedCssClass =

    "selectedHasNoChildren";

     

    }

    }

  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    26 Jun 2009
    Link to this post
    Hello Quade,

    Yes. I was going to suggest you similar approach by checking the levels of the items, but this is doing the job perfectly.

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
8 posts, 0 answered