Telerikuser
Top achievements
Rank 1
Telerikuser
asked on 01 Mar 2010, 07:42 PM
How would I set a parent item to be selected when a child is selected? I want to achieve this in Client Side.
Any help is appreciated.
Any help is appreciated.
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 02 Mar 2010, 11:39 AM
Hello,
You can try the following client code in order to select the parent item of clicked menuitem.
Javascript:
[Attach OnClientItemClicked event to RadMenu]
-Shinu.
You can try the following client code in order to select the parent item of clicked menuitem.
Javascript:
var parent; |
function OnClientItemClicked(sender, args) { |
parent = args.get_item().get_parent(); |
if (parent.get_parent()!= null) |
{ |
setTimeout('parent.set_selected(true);', 200); |
} |
} |
-Shinu.
0
Telerikuser
Top achievements
Rank 1
answered on 03 Mar 2010, 05:49 PM
Thanks. It works. However I want to have bothe parent and child to be selected is it possible? Similar to the HighlightPath in server side.
0
Hello subi,
Please, try the following code:
Best wishes,
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.
Please, try the following code:
<script type=
"text/javascript"
>
function
OnClientItemClicked(sender, args) {
//clear previously selected path
for
(
var
i = 0; i < sender.get_allItems().length; i++) {
sender.get_allItems()[i].set_cssClass(
''
);
}
highLightPath(args.get_item());
}
function
highLightPath(menuItem)
{
menuItem.set_cssClass(
"rmFocused"
);
var
parent = menuItem.get_parent();
if
(parent.get_parent() !=
null
) {
highLightPath(parent);
}
}
</script>
Best wishes,
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
Telerikuser
Top achievements
Rank 1
answered on 09 Mar 2010, 12:06 AM
Thanks for the code. This code works only if I have clickonopen, if I have mouse over open for submenus it is not selecting the parent item. Any help is appreciated.
0
Hi ,
Actually the above code will work when you click the item. It is not necessary to enable the ClickToOpen property.
If you need to run that code on mouse over - then use the OnClientMouseOver event instead of OnClientItemClicked.
Kind regards,
Veskoni
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.
Actually the above code will work when you click the item. It is not necessary to enable the ClickToOpen property.
If you need to run that code on mouse over - then use the OnClientMouseOver event instead of OnClientItemClicked.
Kind regards,
Veskoni
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.