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

[Solved] Cancel drag-drop operation

2 Answers 119 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Oleg
Top achievements
Rank 1
Oleg asked on 02 Feb 2012, 02:09 PM
Hi guys!

I have method assigned to NodeDrop event. It looks like:

function NodeDrop(e) {

    var treeview = jQuery('#TreeView').data('tTreeView');
    var parentId = treeview.getItemValue(e.destinationItem);
    var position = e.dropPosition;
    var result = false;

    jQuery.ajax({
        type: "POST",
        url: '@Url.Action("IsItPossibleToDragDropItem""SomeController"new { area = "Area" })',
        data: { parentId: parentId, position: position },
        dataType: "json",
        async: false,
        success: function (data) {
            if (data.Success) {

		// Here I want to show popup with Cancel button
		
                result = true;
                return;
            }
            else {
                window.alertDialogByTitleMessage(data.Data.Title, data.Data.Message);
                result = false;
                return;
            }
        },
        error: function () {
            window.alertDialog('@ErrorDragDropSelector');
        }
    });
    return result;
}

On success ajax request I need to show popup dialog with cancel button. And when click on it I need to cancel drag-drop. Can I do this? My problem is when I show modal popup after success ajax and click cancel, selected item in tree is moved anyway and after page refresh tree is back to its initial state.


2 Answers, 1 is accepted

Sort by
0
RES
Top achievements
Rank 1
answered on 27 Mar 2012, 01:40 AM
Were you ever able to figure out how to make a synchronous request to determine if a drop is valid?
0
RES
Top achievements
Rank 1
answered on 29 Mar 2012, 06:12 PM
I'm not sure if this is the problem you are having but I was an issue where I wasn't getting any data back from my controller action that that I was using to check the drag and drop.  Turns out the action was returning the following error:

InvalidOperationException: This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.

So I modified my return JSON like the following and it worked.

return Json(new { isValid = result }, JsonRequestBehavior.AllowGet);
Tags
TreeView
Asked by
Oleg
Top achievements
Rank 1
Answers by
RES
Top achievements
Rank 1
Share this question
or