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

RadMenuItem OnClient events anyone?

3 Answers 59 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Tom M
Top achievements
Rank 1
Tom M asked on 13 Aug 2010, 03:54 PM
So I have started working with RadMenu for the first time. It seems you can set an OnClientItemClicking event for the RadMenu, but not the RadMenuItems. Unless I'm missing something, I will have to put all the client-side onClicking logic into one function....does anyone else wish that RadMenuItems had their very own OnClient events?

~Tom

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 13 Aug 2010, 04:35 PM
Hello Tom,

Yes, you understanding of the client side events is correct. Currently, we don't have plans to change the existing implementation of this. Note, that the second argument of your client side handlers carries data about the item so the current implementation should not pose any limitations for RadMenu related to its client-side capability. For example, consider OnClientItemClicking:
<script type="text/javascript">
function onClicking(sender, eventArgs)
{
  var item = eventArgs.get_item();
  var navigateUrl = item.get_navigateUrl();
  if (navigateUrl && navigateUrl != "#")
  {
    var proceed = confirm("Navigate to "+ navigateUrl + " ?");
    if (!proceed)
    {
      eventArgs.set_cancel(true);
    }
    else
    {
      eventArgs.set_cancel(false);
    }
  }
}
</script>

Feel free to contact us if you have further questions.

Greetings,
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
Tom M
Top achievements
Rank 1
answered on 13 Aug 2010, 04:51 PM
Thanks for your reply Peter. I guess the only benefit to RadMenuItems having their own events would be slightly cleaner client-side code. As you mentioned, however, there are no limitations with the current implementation. I just plan on doing something like...

<script type="text/javascript">  
function onClicking(sender, eventArgs)  
{  
  var item = eventArgs.get_item();      
  if (item.get_value() == "myValue") {          
     //logic to handle click for myValue 
  
    
  if (item.get_value() == "myOtherValue") {          
     //logic to handle click for myOtherValue 
  
      
  //etc... 
}  
</script>

Regards,
Tom
0
Peter
Telerik team
answered on 18 Aug 2010, 03:03 PM

Right. Using 'if' checks is the way to go.


Greetings,
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
Tags
Menu
Asked by
Tom M
Top achievements
Rank 1
Answers by
Peter
Telerik team
Tom M
Top achievements
Rank 1
Share this question
or