Question

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?

Was it helpful?

Solution

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));
                }
        }
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top