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

Disable click on parents

4 Answers 88 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Qball
Top achievements
Rank 1
Qball asked on 08 Dec 2009, 02:47 PM
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 

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Dec 2009, 06:54 AM
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.
0
Qball
Top achievements
Rank 1
answered on 09 Dec 2009, 03:26 PM
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
0
steven
Top achievements
Rank 1
answered on 09 Dec 2009, 09:49 PM
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".
0
Qball
Top achievements
Rank 1
answered on 10 Dec 2009, 09:27 AM

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
Tags
Menu
Asked by
Qball
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Qball
Top achievements
Rank 1
steven
Top achievements
Rank 1
Share this question
or