Hello,
after brief exploration of examples and documentation I figured out that Tree Grid in ASP.NET MVC (not WPF) can be rendered only by specifying exact (static columns) defined in some class (eg. viewModel).
For example including this in Razor page:
@(Html.EJ().TreeGrid("TreeGridContainer")
.ChildMapping("Children")
.TreeColumnIndex(1)
.EnableResize(true)
.Columns(co =>
{
if (ViewBag.treeGridDataSource != null)
{
co.F
co.Field("TaskId").HeaderText("Task Id").Width(45).Add();
}
co.Field("TaskName").HeaderText("Task Name").Add();
co.Field("StartDate").HeaderText("Start Date").Add();
co.Field("EndDate").HeaderText("End Date").Add();
co.Field("Duration").HeaderText("Duration").Add();
co.Field("Progress").HeaderText("Progress").Add();
}
)
.SizeSettings(ss => ss.Width("100%").Height("600px"))
.Datasource(ViewBag.treeGridDataSource)
)
However I want to render columns dynamically according to user settings. Not only hide or show specific (earlier specified, hard typed) columns. For example I want to write something like foreach(var ViewBag.ColumnList){ co.Field("ColumnListItem.Name").HeaderText("ColumnListItem.HeaderText").Add(); }
Is it somehow possible to generate dynamic columns in Tree Grid for ASP.NET MVC?
Thanks all,
Martin Rasovsky