Domanda

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?

È stato utile?

Soluzione

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));
                }
        }
    }
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top