Disable top menu item?

2 posts, 1 answers
  1. Josh
    Josh avatar
    35 posts
    Member since:
    Nov 2007

    Posted 19 May 2008 Link to this post

    Top Menu Item
        - Action A   
        - Action B

    I've got a radmenu, using onitemclick to handle events on the server - is there anyway to disable postback for the top menu item so there is only post back when clicking one of the items? Can't seem to find an easy solution for this...

  2. Answer
    Simon
    Admin
    Simon avatar
    2281 posts

    Posted 22 May 2008 Link to this post

    Hello Josh,

    Thank you for writing to us.

    There are two ways of accomplishing this:
    1. Set the PostBack property to false of those Items which you do not want to do a postback upon clicking:
      <telerik:RadMenuItem Text="Text" Value="Value" PostBack="false"></telerik:RadMenuItem> 
    2. Handle the OnClientItemClicking client-side event and cancel the event if the clicked Item is a root Item (canceling the OnClientItemClickcing event will prevent the postback):
              function OnClientItemClicking(sender, eventArgs) 
              { 
                  var item = eventArgs.get_item(); 
                   
                  var rootItems = sender.get_items(); 
                   
                  if (rootItems.indexOf(item) > -1) 
                  { 
                      eventArgs.set_cancel(true); 
                  } 
              } 
    You could read more about the client-side functions and events used here:
    I have also attached a sample project which demonstrates both approaches described above.

    I hope this helps.

    Sincerely yours,
    Simon
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top