kendo ui cancel treeview drop

一世执手 提交于 2019-12-11 00:17:54

问题


i have a TreeView that once the user drops the item to the desired position, it displays a dialog box and asks for confirmation, if the user selects cancel, how would i also cancel the placement of the item so it goes back to its original position? my current code is below but isnt working:

var newDiv = $(document.createElement('div'));

newDiv.html('Are you sure you want to move the item: ' + title);
newDiv.dialog( {
    autoOpen: true,
    width: 600,
    buttons: {
        "Save": function () {
            $(this).dialog("close");
        },
        "Cancel": function () {
            $(this).dialog("close");

            e.setValid = false;

        }
    }
});

I have also tried doing the same kind of code on the dragend event and using e.preventDefault(); with no more luck


回答1:


The drop event handler provides the setValid function, which can prevent the drop from occurring. For example:

function onDrop(e) {
    e.setValid(confirm('Do you wish to move this item here?'));
}

$("#treeView").kendoTreeView({
    // ...
    dragAndDrop: true,
    drop: onDrop
});

I've written a fiddle which demonstrates how this works.




回答2:


Did you try to use the drop event and call prevent default there if the condition is not satisfied?



来源:https://stackoverflow.com/questions/9995029/kendo-ui-cancel-treeview-drop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!