문제

I am using Dynatree with ASP.NET and MVC4, I was able to Initialize Tree with the Data from Server end.

My question is how i can send data back to server on certain tree modifications. (For example Edit Node, Cut Copy Paste, Drag drop etc.)

Is there any working example to look at?

도움이 되었습니까?

해결책

The easiest way is to do an Ajax call to the server and pass relevant data from the corresponding dynatree event handler. For example, for drag'n'drop, you would do smth like:

$("#tree").dynatree({
    dnd: {
        onDrop: function(node, sourceNode, hitMode, ui, draggable) {
            $.ajax({
                type: "POST",
                url: [url],
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                data: JSON.stringify(node.data),
                success: function (arg) {
                    alert(JSON.stringify(arg));
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert(JSON.stringify(xhr.responseText));
                }
        }
    }
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top