I'm using ajax() binding on my grid datasource. (MVC Server Wrappers)
I have a PopUp Editor comming up showing my data i want to edit.
I want to display multiple checkboxes for one value. (have a look at the attached screenshot)
But when i select one checkbox, all other checkboxes get selected as well.
Do you have any clue?
Best regards,
Daniel
8 Answers, 1 is accepted

Here is some additional information what my HTML looks like.
The amount of checkboxes is dynamic...
For rendering i use: i use a editor template like:
@model ZielgruppenCheckboxViewModel
@model ZielgruppenCheckboxViewModel
@{
Model.AvailableZielgruppen = ViewData["AvailableZielgruppen"] as List<
ZielgruppeViewModel
>;
var htmlListInfo = new HtmlListInfo(HtmlTag.vertical_columns, 0, new { @class="checkboxlist" }, TextLayout.Default, TemplateIsUsed.No);
}
@Html.CheckBoxListFor(model => model.PostedZielgruppen.ZielgruppenIds,
model => model.AvailableZielgruppen,
entity => entity.Id,
entity => entity.Name,
model => model.SelectedZielgruppen,
htmlListInfo
)

I have the same problem,
While editing the existing records it is working just fine. But while creating all checkboxes gets selected when I select any checkbox.
Daniel, have you found a solution yet?
Anybody ?
The issue was resolved in a private support ticket.
The described problem will occur if the value in the dataSource model is not an array. In this case the checkboxes will not be bound as list. Their checked state will be bound to the model value. Here is an example that demonstrates the difference.
As for removing the data-bind attribute - you can add a data-skip attribute to the checkboxes in order to prevent the attribute to be added automatically based on the name:
@Html.CheckBoxListFor(model => model.PostedZielgruppen.ZielgruppenIds,
model => model.AvailableZielgruppen,
entity => entity.Id,
entity => entity.Name,
model => model.SelectedZielgruppen,
htmlListInfo,
entity =>
new
{ data_skip =
"true"
}
)
I hope this information will help.
Regards,
Alexander Valchev
Telerik

I am generating checkboxes like this...
<
ul
>
@foreach (var g in (System.Web.Mvc.MultiSelectList)ViewData["BondPermitTypes"])
{
<
li
>
<
label
>
<
input
type
=
"checkbox"
name
=
"Category"
id
=
"Category_@g.Value"
value
=
"@g.Value.ToString()"
/>@g.Text
</
label
>
</
li
>
}
</
ul
>
Generating like above works perfectly ok when I am editing existing records. The Category of the model will have the list of values that will be selected from the list of checkboxes. But while creating new records all of the checkboxes are getting checked.
If I use data-skip="true", even editing does not work.
Would you be able to create a working project and send it for me.
Thank you!
We do not have example that matches your requirements.
Is it possible for you to isolate the scenario in a separate project with mock data? In this way I will be able to examine what is going wrong and assist you further.
Regards,
Alexander Valchev
Telerik

Hello Alexander,
I have attached an isolated project.
Since it only allows maximum of 2 MB file size. You will need to install asp.net mvc nuget package and others as needed.
Please go to Home/KendoGrid to view the Grid. I strongly hope that you will send me back a working project asap.
Please also make sure that the CreateUser and UpdateUser are sending right Roles list (see in the project)
Thank you very much!
I was able to run and examine the provided project.
The issue occurs because the newly created item does not have 'Roles' property. In order to resolve the issue you should set default value for the 'Roles' field. The default value should be array.
Please check the sample from this help article as it explains how to set default value of a model field.
Regards,
Alexander Valchev
Telerik

It WORRRKS !!!
Thank you very much Alexander. You are great.