This is a migrated thread and some comments may be shown as answers.

how to bind CheckBoxGroupFor to module?

1 Answer 408 Views
CheckBoxGroup
This is a migrated thread and some comments may be shown as answers.
Wilbert
Top achievements
Rank 1
Wilbert asked on 20 Mar 2021, 10:19 PM

following is my code, but not bind to model
                @Html.Kendo().CheckBoxGroupFor(m => m.weekOfDay).Items(i =>
                {
                    i.Add().Label("ma").Value("1");
                    i.Add().Label("di").Value("2");
                    i.Add().Label("wo").Value("3");
                    i.Add().Label("do").Value("4");
                    i.Add().Label("vr").Value("5");
                    i.Add().Label("za").Value("6");
                    i.Add().Label("zo").Value("0");
                }).Layout("horizontal")

 

cannot find any online information.

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 24 Mar 2021, 02:39 PM

Hi, Wilbert,

The CheckBoxGroupFor helper needs to be bound to an IEnumerable<string> property and you would also have to manually set the data binding using HtmlAttributes().

.Layout("horizontal")
.HtmlAttributes(new { data_bind = "value: weekOfDay" });

I am attaching a sample project which you can examine locally and see how to use the helper and display the values on the grid.

Let me know if you have any questions.

Best Regards,
Georgi Denchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
CheckBoxGroup
Asked by
Wilbert
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Share this question
or