Hi:
I have a Company entity with a collection of child Employee entities. The controller is defined like this:
The company entities appear in the first level of the treeview correctly. Where there are employees, the graphic on the left appears, but when I try to click on it to show them, it disappears. As you can see, I am renaming the columns in the employee records to match the same names so they should bind correctly, shouldn't they? I've looked at the remote data example, but the demos won't work on my machine (I've got another post asking about that), so I can't see what the json string should look like.
My Razor MVC cshtml looks like this:
The employee entities exist correctly when I view them from the controller code. Can you tell me what I am missing?
Thanks,
Terry
I have a Company entity with a collection of child Employee entities. The controller is defined like this:
public
JsonResult JsonIndex()
{
//var allCompanies = _db.Companies;
var allCompanies = from c
in
_db.Companies
select
new
{
CompanyName = c.CompanyName,
hasChildren = c.Employees.Any(),
ImageUrl =
"/Images/icons/Employee3_16.png"
,
children = from e
in
c.Employees
select
new
{
CompanyName = e.FirstName,
hasChildren =
false
,
ImageUrl =
"/Images/icons/Company20_16.png"
,
}
};
JsonResult json = Json( allCompanies,JsonRequestBehavior.AllowGet );
return
(json);
}
My Razor MVC cshtml looks like this:
@(Html.Kendo().TreeView()
.Name("treeview2")
.DataTextField("CompanyName")
.DataImageUrlField("ImageUrl")
.LoadOnDemand(true)
.HighlightPath(true)
.Events( events =>
events.Change( "onTreeViewChange")
)
.DataSource(dataSource => dataSource
.Read(read => read
.Action("JsonIndex", "Home")
)
)
)
Thanks,
Terry