radtreeviewcontextmenu with radconfirm dialog

2 posts, 1 answers
  1. orim
    orim avatar
    29 posts
    Member since:
    Mar 2012

    Posted 05 Aug 2013 Link to this post

    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
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Aug 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top