RadMenuItem OnClient events anyone?

4 posts, 0 answers
  1. Tom M
    Tom M avatar
    33 posts
    Member since:
    Nov 2009

    Posted 13 Aug 2010 Link to this post

    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
  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 13 Aug 2010 Link to this post

    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
  3. Tom M
    Tom M avatar
    33 posts
    Member since:
    Nov 2009

    Posted 13 Aug 2010 Link to this post

    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
  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 18 Aug 2010 Link to this post


    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
Back to Top