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