
Josh Smith
Top achievements
Rank 1
Josh Smith
asked on 22 Jan 2008, 04:48 PM
If I want a menu to open only when someone clicks on the menu, how do I access what is clicked on inside the menu? When I try to use both of the properties OnItemClick is fired which causes a postback and ClickToOpen does not work properly.
Thank you.
Thank you.
4 Answers, 1 is accepted
0
Hello Josh Smith,
It is better to handle the ItemClick events on the client.
Consider the following sample code:
Hope this helps
Kind regards,
Veskoni
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
It is better to handle the ItemClick events on the client.
Consider the following sample code:
<telerik:RadMenu ID="RadMenu1" runat="server" |
ClickToOpen="True" Flow="Horizontal" |
OnClientItemClicking="beforeClientClick"> |
<script type="text/javascript"> |
function beforeClientClick(sender, eventArgs) |
{ |
var item = eventArgs.get_item(); |
if (item.get_parent() == sender) |
{ |
//root item clicked |
} |
else |
{ |
//child item clicked |
} |
} |
</script> |
Hope this helps
Kind regards,
Veskoni
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Josh Smith
Top achievements
Rank 1
answered on 23 Jan 2008, 10:49 PM
What if I wanted to execute server side code OnItemClicked?
0
Accepted
Hello Josh Smith,
Please take a look at the example I created for you and attached to this thread.
It uses ItemClick server side event, ClickToOpen set to true and after the postback - the menu is expanded as needed.
Hope this helps.
Regards,
Veskoni
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Please take a look at the example I created for you and attached to this thread.
It uses ItemClick server side event, ClickToOpen set to true and after the postback - the menu is expanded as needed.
Hope this helps.
Regards,
Veskoni
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Toan
Top achievements
Rank 1
answered on 12 Oct 2012, 08:37 PM
I also wanted to do the same thing. That is to show menu only on mouse click and not on mouse over. I played around with the suggestions above and this is what i came up with. It seems to work. Essentially, i have to override the behavior of the client mouse click event (OnClientItemClicking).
<
script
type
=
"text/javascript"
>
function OnClientItemClicking(sender, eventArgs)
{
var radMenuItem = eventArgs.get_item();
if (radMenuItem._hasItems) {
radMenuItem.open();
radMenuItem.focus();
eventArgs.set_cancel(true);
}
}
</
script
>
<
telerik:RadMenu
ID
=
"menuRoot"
runat
=
"server"
ClickToOpen
=
"true"
OnClientItemClicking
=
"OnClientItemClicking"
>
</
telerik:RadMenu
>