Binding
When using the Tag helpers you can bind the checkbox items by using the <kendo-checkboxgroup-items>
tag or the bind-to() method.
Items method
The example below demonstrates how to use the <kendo-checkboxgroup-items>
tag to configure the checkboxes in the CheckBoxGroup widget.
<kendo-checkboxgroup name="checkboxgroup">
<kendo-checkboxgroup-items>
<kendo-checkboxgroup-item value="one" label="First">
</kendo-checkboxgroup-item>
<kendo-checkboxgroup-item value="two" label="Second">
</kendo-checkboxgroup-item>
</kendo-checkboxgroup-items>
</kendo-checkboxgroup>
BindTo method
You can configure the items in the CheckBoxGroup widget by using the BindTo method.
-
Pass the data to the view through the view model.
public IActionResult Index() { var itemsList = new List<InputGroupItem>() { new InputGroupItem() { Label = "Yes", Value = "one" }, new InputGroupItem() { Label = "No", Value = "two" }, new InputGroupItem() { Label = "N/A", Value = "three" } }; return View(new CheckBoxGroupViewModel() { Items = itemsList }); } public class CheckBoxGroupViewModel { public List<InputGroupItem> Items { get; set; } }
-
Add the CheckBoxGroup to the view and bind it to a property of the view model.
@model MvcApplication1.Models.CheckBoxGroupViewModel <kendo-checkboxgroup name="checkboxgroup" input-name="checkboxItem" bind-to="Model.Items"> </kendo-checkboxgroup>