This is a migrated thread and some comments may be shown as answers.

Set style of root radmenuitem when child item is selected.

2 Answers 97 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Big Daftie
Top achievements
Rank 1
Big Daftie asked on 24 Sep 2010, 11:27 PM
Hi all,

I'm attempting to set the style of a root menuitem to it's focussed state when an item in its submenu has been selected. I'm doing this in a master page, code as follows:

Private Sub sitemenu_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs) Handles sitemenu.ItemCreated
        Dim item As RadMenuItem = sitemenu.FindItemByUrl(Request.Url.PathAndQuery)
        If item IsNot Nothing Then
            item.CssClass = "focused"
        End If
 
    End Sub


This works great, and the root items show the focussed state when clicking between them. However when i click on a child item, the root menu item does not have the focused class added to it. Any pointers? 

2 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 28 Sep 2010, 03:18 PM
Hello Big Daftie,

Please, see the Show Path And BreadCrumb demo. Basically,  you need to call the HighlightPath() method of the current item.


All the best,
Peter
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
0
Big Daftie
Top achievements
Rank 1
answered on 28 Sep 2010, 03:26 PM
Hi there Peter,

thanks for you reply. I actually sorted this myself - I was using loadcontentfromfile(), which did not databind the xml so could not use the itemdatabound() handler.

I've now moved the code to itemdatabound, and modified it to the following (in the unlikely event it's of use to anyone else):

Dim item As RadMenuItem = sitemenu.FindItemByUrl(Request.Url.PathAndQuery)
If item IsNot Nothing Then
    If item.Level > 0 Then 'menu will only ever be one level deep
        Dim rootitem As RadMenuItem = item.Parent
        rootitem.CssClass = "focused"
    End If
    item.CssClass = "focused"
End If

This seems to work fine - however I'm looking at your breadcrumb demo just now :)

Many thanks!

Tags
Menu
Asked by
Big Daftie
Top achievements
Rank 1
Answers by
Peter
Telerik team
Big Daftie
Top achievements
Rank 1
Share this question
or