Disable click on parents

5 posts, 0 answers
  1. Qball
    Qball avatar
    8 posts
    Member since:
    Dec 2009

    Posted 08 Dec 2009 Link to this post

    Hi all.

    I'm not sure if I have caused this problem because I haven't designed my database correctly or there is a simple solution with the menu.

    I have a rad menu that is populated from my database.  For every new page created a MenuID (int) is created.  Some of the menuID will have sub menu's (parentID and ChildID)

    OK so here is my problem: Every node in my menu is clickable I want to some how disable parent links.

    Top level links need to be clickable as they have no children, but Top level links with children need to just show their child sub menu's

    Reading this back I can see why I'm having trouble, I can't even describe my problem very well!!

    Hope someone can understand.
    Thanks 
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Dec 2009 Link to this post

    Hi Oball,

    Attach 'OnClientItemClicking' event in order to cancel the click based on whenther the clicked node has children and the level.

    JavaScript:
     
    <script type="text/javascript"
        function OnClientItemClicking(sender, args) { 
            if (args.get_item().get_items().get_count() != 0 && args.get_item().get_level() ==0) { 
                alert("Cancelled"); 
                args.set_cancel(true); // Cancel the event 
            } 
        } 
    </script> 

    -Shinu.
  3. Qball
    Qball avatar
    8 posts
    Member since:
    Dec 2009

    Posted 09 Dec 2009 Link to this post

    Hi Shinu

    Thank you so much for the post.

    I ran the code example but received the following error:

    A webpage error box opened with the following meessage:
     
    Line: 1
    Error: 'onClicking' is undefined

    In my RadMenu I have this code:

    OnClientItemClicking

     

    ="onClicking"

     

     


    And the script you provided:

     

     

     

    <script type="text/javascript">  
        function OnClientItemClicking(sender, args) {  
            if (args.get_item().get_items().get_count() != 0 && args.get_item().get_level() == 0) {  
                alert("Cancelled");  
                args.set_cancel(true); // Cancel the event    
            }  
        }    
    </script>   

     



    Am I referencing this incorrectly OnClientItemClicking="onClicking" ???

    Many Thanks
  4. steven
    steven avatar
    7 posts
    Member since:
    Jun 2006

    Posted 09 Dec 2009 Link to this post

    your error tell you exacty what it is, onClicking is undefined because it wasn't defined. you can either change the sample script function name to "onClicking", or just OnClientItemClicking="OnClientItemClicking".
  5. Qball
    Qball avatar
    8 posts
    Member since:
    Dec 2009

    Posted 10 Dec 2009 Link to this post

    Oh,  now I understand, learning as I go along here!! 

    Now I'm calling the function  I get the following  Error: Object doesn't support this property or method

    Do I have to change this line of code?

    if (args.get_item().get_items().get_count() != 0 && args.get_item().get_level() == 0) {  
     

    Thanks
Back to Top