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

Confirmation Message

4 Answers 100 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Manoj
Top achievements
Rank 1
Manoj asked on 03 Mar 2009, 01:15 PM

Hi Team,
    I am using a tree view . When user will right click on any of the node he can able to add a child node . But fore that I want to display a confirmation message . If he/she confirms then only he can able to add a new child node . For this I have written the bellow mentioned code . It is working for when user is confirms but it not working when user not confirming it . It is giving error at
"args.set_cancel(true);" . Can you please help me out .

 

 

function

onClientContextMenuItemClicked(sender, args)

 

{

 

var menuItem = args.get_menuItem();

 

 

var treeNode = args.get_node();

 

 

if (!confirm("Do you really want to add a new value. ? "))

 

{

args.set_cancel(

true);

 

}

 

else

 

{

 

switch(menuItem.get_value())

 

{

 

case "NewValue":

 

 

break;

 

}

}

}


With Regards
Manoj

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Mar 2009, 04:48 AM
Hi Manoj,

Attach the function to OnClientContextMenuItemClicking  event of RadTreeView instead of OnClientContextMenuItemClicked. The OnClientContextMenuItemClicking client-side event occurs when the user clicks a menu item, but before the OnClientContextMenuItemClicked event fires, and performing any action for contextmenuitem click and can be canceled.

Thanks,
Princy.
0
Manoj
Top achievements
Rank 1
answered on 04 Mar 2009, 09:46 AM
 
0
Manoj
Top achievements
Rank 1
answered on 04 Mar 2009, 10:45 AM
Hi Princy,
    Thanks for your reply . I used the OnClientContextMenuItemClicking event earier , but issue was when you don't confirm the message still the context menu item was displaying , if you clicked outside once then only the context menu item is removing . Can you suggest me what should I do in this case .

Regards
Manoj
0
Veselin Vasilev
Telerik team
answered on 04 Mar 2009, 11:53 AM
Hi Manoj,

Canceling the OnClientContextMenuItemClicking means that the click on the menu item is canceled. It does not mean the menu would close. You can close it by yourself (using the hide() or close() javascript methods).

I hope this helps.

Kind regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
Manoj
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Manoj
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or