I have a KendoTreeView which is bound to a HierarchicalDataSource
and filled from a parent/child Table from DB. I have an ADD button to add child node to selected node.
The below is my code:
var dataSource = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: "@Url.Action("Folder_Read", "Home")",
dataType: "json",
contentType: 'application/json; charset=utf-8',
type: 'GET'
}
},
schema: {
model: {
id: "fol_ID",
hasChildren: "fol_HasChildren"
}
}
});
var treeview = $("#treeview-folder").kendoTreeView({
template: kendo.template($("#treeview-template").html()),
checkboxes: {
checkChildren: false
},
dataSource: dataSource,
dataTextField: "fol_Title",
select: select_tree,
});
$("#appendNodeToSelected").click(function (event) {
var selectedNode = treeview.data("kendoTreeView").select();
if (selectedNode.length == 0) {
selectedNode = null;
}
var nodeText = prompt("Please enter desired Node name", "Default");
if (nodeText == null) {
return;
}
var obj= treeview.append(
{ fol_ID: 0, fol_Title: nodeText }
, selectedNode
);
});
but this is not worked as well. The child folder isn't add neither visually or call controller. How can I define an action and controller for it to add child node to DB ?????
I found out my mistake finally. I had forgotten to write treeview.data("kendoTreeView").append
instead of treeview.append
.The child folder now is added visually.