New to Telerik UI for ASP.NET Core? Download free 30-day trial

Bind CheckBoxes in the TreeList

Environment

Product Telerik UI for ASP.NET Core TreeList

Description

How can I add a checkbox column to the TreeList which will set an initial checked or unchecked state of the checkboxes based on the model values?

Solution

Use the template method of the TreeList column.

columns.Add().Field(e => e.CheckBoxColumnField).Template(
        "#if(CheckBoxColumnField == true){#" +
            Html.Kendo().CheckBox().Name("name#:CheckBoxColumnField#").HtmlAttributes(new { @class = "CheckBoxColumnField" }).Checked(true).ToHtmlString() +
        "#}else{#" +
            Html.Kendo().CheckBox().Name("name#:CheckBoxColumnField#").HtmlAttributes(new { @class = "CheckBoxColumnField" }).ToHtmlString() +
        "#}#"
    );

More ASP.NET Core TreeList Resources

See Also

In this article