BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
@(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)
)
Hi Martin,
Thanks for contacting Syncfusion support.
We can render dynamic columns based on the conditions in ASP.Net MVC TreeGrid as you have done in your code example. Please refer the below code example for details.
@(Html.EJ().TreeGrid("TreeGridContainer") //… .Columns(co => { if (ViewBag.dataSource == null) { co.Field("Id").HeaderText("Task Id").Width(45).Add(); } co.Field("Name").HeaderText("Task Name").Add(); co.Field("StartDate").HeaderText("Start Date").Add(); co.Field("Duration").HeaderText("Duration").Add(); co.Field("PercentDone").HeaderText("Progress").Add(); } ) .Datasource(ViewBag.dataSource) ) |
We have also prepared a sample based on this and you can find the sample under the following location.
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/DynamicColumn2079197477
Note: We have removed bin and obj folder in the given sample for some security reasons, we must include Syncfusion.EJ and Syncfusion.EJ.MVC dlls to render the TreeGrid control which is available in Essential studio installed location
Regards,
Mahalakshmi K.