Hello,
I am trying to bind my treeview to a datasource provided by a controller function, using two examples provided by Telerik, on the web site and at the demos project. My goal is to use the script call from used in one demo with the controller data source used in the other, but I am not being able to do it.
This is the script code:
<script>
var serviceRoot = "https://demos.telerik.com/kendo-ui/service";
homogeneous = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: "api/Servicos/Employees",
dataType: "jsonp"
}
},
schema: {
model: {
id: "SetorId",
hasChildren: "hasChildren"
}
}
});
$("#treeview").kendoTreeView({
dataSource: homogeneous,
dataTextField: "Nome"
});
</script>
And this is the Controller code:
[Route("Employees")] [HttpGet] public JsonResult Employees() { var result = _unitOfWork.SetorSolicitante.GetAll(); { var employees = from e in result select new { id = e.SetorSolicitanteId, Name = e.Nome, hasChildren = (from q in _unitOfWork.SetorSolicitante.GetAll() where (q.SetorPaiId == e.SetorSolicitanteId) select q ).Count() > 0 }; return new JsonResult(employees.ToList()); } }
My table references itself, where SetorPaiId indicates if the SetorId is a child of it.
Could I get some assistance on that issue?
Regards,
Alexandre