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

Forums / Designing with Sitefinity / LastExpandLevel not works in IE7

LastExpandLevel not works in IE7

6 posts, 0 answered
  1. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    07 Oct 2010
    Link to this post
    Hi,

    I've got a weird issue in IE7.
    When I set the LastExpandLevel to 0 inside my sitemenu, it acts weird in IE7.

    If I don't change the LastExpandLevel property, then I have the following problem:

    1. I select a page in the menu.
    2. The item gets the hover state (rmFocused)
    3. I select a subpage from another menu control, based on the same sitemap.
    4. The submenu item gets the hover state
    5. The main menu lost its hover state.

    If I set the LastExpandLevel to 0 then I get the desired behaviour. But in IE7 the whole menu background dissapears when I hover the menuitems on the main menu??

    Really strange behaviour.

    I don't want to display submenu items, only the root level of my sitemap which are e.g. 5 pages. When I select a subpage (via another menu) I want the parent menu item also to be selected. I thought this was default behaviour?

    Regards,
    Daniel
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    07 Oct 2010
    Link to this post
    Hi Daniel Plomp,

    Thank you for using our services.

    The problem is that the site menu is not populated with the children items and thus it does not know that you are on a page which belongs to a certain parent. What you have to do is to create another menu which will be a copy of SiteMenu however will have the bellow code which will detect the parent root item and set it as selected:

    protected void Page_Load(object sender, EventArgs e)
    {
        RadMenu1.DataBound += new EventHandler(RadMenu1_DataBound);
    }
     
    void RadMenu1_DataBound(object sender, EventArgs e)
    {
        CmsSiteMapNode currentNode = (CmsSiteMapNode)SiteMap.CurrentNode;
        CmsSiteMapNode node = GetRootParent(currentNode);
        RadMenuItem rootitem = RadMenu1.FindItemByText(node.CmsPage.MenuName);
        if (rootitem != null)
            rootitem.Selected = true;
    }
     
    private CmsSiteMapNode GetRootParent(CmsSiteMapNode node)
    {
        if (node.CmsPage.Parent == null)
            return node;
        return GetRootParent((CmsSiteMapNode)node.ParentNode);
    }


    Best wishes,
    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. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    08 Oct 2010
    Link to this post
    Hi Radoslav,

    I tried this, but it doesn't have any effect.
    Which property should I set?

    LastExpandLevel = 0 or LastExpandLevel = 1 ?
    There is also a MaxDataBindDepth property?

    The FindItemByText returns 'null' if I select a subpage.
    Maybe because I select subpages from another menu on the site (although it should be the same sitemap)?

    Regards,
    Daniel

  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    08 Oct 2010
    Link to this post
    Hi Daniel Plomp,

    There is no problem with the code on your side. The issue is that you are using rmFocused class for defining which is the selected item. The code sets the class rmSelected to the top level item. What yo can do is try this one out:
    void RadMenu1_DataBound(object sender, EventArgs e)
    {
        CmsSiteMapNode currentNode = (CmsSiteMapNode)SiteMap.CurrentNode;
        CmsSiteMapNode node = GetRootParent(currentNode);
        RadMenuItem rootitem = RadMenu1.FindItemByText(node.CmsPage.MenuName);
        if (rootitem != null)
        {
            rootitem.SelectedCssClass = "rmFocused";
            rootitem.Selected = true;
        }
    }


    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. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    08 Oct 2010
    Link to this post
    Ah. I see how that works now.
    Thanks!

    I only get some errors in the Sitefinity Backend, when selecting a template in the added code.

    But I'll debug that first....

    Regards,
    Daniel
  6. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    08 Oct 2010
    Link to this post
    Okay, some checks did the trick:

    void RadMenu1_DataBound(object sender, EventArgs e)
    {
        CmsSiteMapNode currentNode = (CmsSiteMapNode)SiteMap.CurrentNode;
        if (currentNode != null)
        {
           CmsSiteMapNode node = GetRootParent(currentNode);
           RadMenuItem rootitem = RadMenu1.FindItemByText(node.CmsPage.MenuName);
           if (rootitem != null)
           {
              rootitem.SelectedCssClass = "rmFocused";
              rootitem.Selected = true;
           }
        }
    }

    Thanks for the help!

    -Daniel-
Register for webinar
6 posts, 0 answered