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

How to prevent NodeDrop event fire before RadAjaxManager1_AjaxRequest

2 Answers 58 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Huy
Top achievements
Rank 1
Huy asked on 29 Oct 2014, 09:31 AM
I have a page with Radtreeview enable drag & drop. I implement a radconfirm to check exist node name when drop nodes

Script on client node dropping

 
function onNodeDropping(sender, args) {
           var dest = args.get_destNode();
           var source = args.get_sourceNode();
           if (dest) {
               var result = false;
               for (var i = 0; i < dest.get_nodes().get_count() ; i++) {
                   var node = dest.get_nodes().getNode(i);
                   if (node.get_text() == source.get_text()) {
                       result = true;
                       break;
                   }
               }
               if (result) {
                   callConfirm(source.get_text());
                   return;
               }
           }
           else {
               dropOnHtmlElement(args);
           }
       }

And code to call confirm :

function callConfirm(nodeText) {
                        radconfirm(nodeText + ' folder is existing, Do you want to overwrite?', confirmCallBackFn);
                        return false;
                    }
                    function confirmCallBackFn(arg) {
                        var ajaxManager = $find("<%=RadAjaxManager1.ClientID%>");
                   if (arg) {
                       ajaxManager.ajaxRequest('ok');
                   }
                   else {
                       ajaxManager.ajaxRequest('cancel');
                   }

Code of RadAjaxManager1_AjaxRequest
if (e.Argument.ToString() == "ok")
            {
                lbStatus.Text = "OK";
            }
            else if(e.Argument.ToString() == "cancel")
            {
                lbStatus.Text = "Cancel";
            }

But when drop an item on Radtreeview to another Node that the same node name, RadTreeView_NodeDrop event always fire before RadAjaxManager1_AjaxRequest. How to solve it?


2 Answers, 1 is accepted

Sort by
0
Huy
Top achievements
Rank 1
answered on 29 Oct 2014, 09:56 AM
Update: Confirmbox show on the same time with RadTreeView_NodeDrop event fire.

I want them follow with sequence :
User drag item to others node > if it has same node name > show confirm box > User choose Yes or No > fire event RadAjaxManager1_AjaxRequest > fire event RadTreeView_NodeDrop

But current sequence is :User drag item to others node > same node name > show confirm box + fire event RadTreeView_NodeDrop
0
Hristo Valyavicharski
Telerik team
answered on 03 Nov 2014, 08:40 AM
Hi Huy,

I suggest you cancel the OnClientNodeDropping event in case the user click on the "Cancel" button in the radconfirm window. This way you will no longer need OnAjaxRequest event and you can move your server logic in the RadTreeView_NodeDrop event and

Regards,
Hristo Valyavicharski
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TreeView
Asked by
Huy
Top achievements
Rank 1
Answers by
Huy
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Share this question
or