New to Kendo UI for jQueryStart a free 30-day trial

Bind Checkboxes in the Kendo UI TreeList for ASP.NET MVC

Environment

ProductProgress® Telerik® UI TreeList for ASP.NET Core
Operating SystemWindows 10 64bit
BrowserGoogle Chrome
Browser VersionVersie 62.0.3202.94
.NET FrameworkVersion 4.7
Visual Studio VersionVisual Studio 2017
Preferred LanguageC Sharp

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.

js
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() +
        "#}#"
    );
In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support