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

radtreeviewcontextmenu with radconfirm dialog

1 Answer 28 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
orim
Top achievements
Rank 1
orim asked on 05 Aug 2013, 11:10 AM
Hi,
i have some problems with radconfirm in contextmenu of a treeview.
In treeview i want to delete node when click on "Delete" contextemenuitem - I pop up a client side radconfirm dialog.
radconfirm('Are you sure you want to delete this folder: ' + treeNode.get_text(),
confirmCallBackFn, 330, 180,
null, 'Folder-Delete');
if user click "OK" i need to execute the server side code
RadTreeView1_ContextMenu1ItemClick
but this event get not hit
function confirmCallBackFn(arg) {
 
    //the user clicked OK
    if (arg)
    {
        __doPostBack('<%= RadTreeView1ContextMenu1.Items(3).UniqueId%>', '');
     }
 
}
Help please

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 05 Aug 2013, 12:30 PM
Hi orim,

Please have a look into the following code I tried which works fine at my end.

ASPX:
<telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientContextMenuItemClicking="OnClientContextMenuItemClicking"
    OnContextMenuItemClick="RadTreeView1_ContextMenuItemClick">
    .....
</telerik:RadTreeView>

JavaScript:
<script type="text/javascript">
    var clickCalledAfterRadconfirm = false;
    var menuItem;
    function OnClientContextMenuItemClicking(sender, args) {
        if (!clickCalledAfterRadconfirm) {
            args.set_cancel(true);
            menuItem = args.get_menuItem();
            radconfirm("Are you sure you want to Delete?", confirmCallbackFunction);
        }
    }
    function confirmCallbackFunction(args) {
        if (args) {
            clickCalledAfterRadconfirm = true;
            menuItem.click();
        }
        else {
            clickCalledAfterRadconfirm = false;
        }
        menuItem = null;
    }
</script>

C#:
protected void RadTreeView1_ContextMenuItemClick(object sender, Telerik.Web.UI.RadTreeViewContextMenuEventArgs e)
{
    //your  code to delete
}

Thanks,
Shinu.
Tags
TreeView
Asked by
orim
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or