|
|
|
|
|
|
|
<ejs-button id="element" content="Button"></ejs-button>
<ejs-treeview id="listdata" allowDragAndDrop="true">
<e-treeview-fields dataSource="ViewBag.dataSource" id="id" parentId="pid" text="name" hasChildren="hasChild" expanded="expanded"></e-treeview-fields>
</ejs-treeview>
<script>
document.getElementById('element').onclick = function (e) {
var treeView_instance = document.getElementById("listdata").ej2_instances[0];
console.log(treeView_instance.getTreeData());
}
</script> |
|
<ejs-treeview id="listdata" allowDragAndDrop="true" nodeDropped="nodeDropped">
<e-treeview-fields dataSource="ViewBag.dataSource" id="id" parentId="pid" text="name" hasChildren="hasChild" expanded="expanded"></e-treeview-fields>
</ejs-treeview>
<script>
function nodeDropped(args) {
var treeView_instance = document.getElementById("listdata").ej2_instances[0];
var full_data = treeView_instance.getTreeData();
var formData = new FormData();
formData.append("tree-data", JSON.stringify(full_data));
$.ajax({
url: '/Home/Index1',
type: 'POST',
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (result) {
},
error: function (xhr, status) {
console.log(status);
},
})
}
</script>
[HttpPost]
public ActionResult Index1(IFormCollection formCollection)
{
string json = formCollection["tree-data"];
return Json("");
} |