|
<button id="button" (click)="click($event)">Load Datasource</button>
click(args) {
$.ajax({
// Send the request to the controller side to fetch the TreeView datasource
type: "POST",
dataType: "json",
success: function(result) {
var tree = document.getElementById("default").ej2_instances[0];
// Update the datasource aftetr fetching the data from controller side.
tree.fields ={ dataSource: result,id: "id", parentID: "pid", text: "groupname", hasChildren: "hasChild"}
},
error: function(xhr, status) {
console.log(status);
}
});
} |