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

Howto remove "data-bind" Attribute from Grid PopUp Editor

8 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 09 Sep 2014, 01:21 AM
Hi,

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

Sort by
0
Daniel
Top achievements
Rank 1
answered on 09 Sep 2014, 11:33 AM

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
)

0
Saquib
Top achievements
Rank 1
answered on 01 Jun 2015, 06:38 PM

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 ?

 

0
Alexander Valchev
Telerik team
answered on 03 Jun 2015, 03:52 PM
Hi Saquib,

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Saquib
Top achievements
Rank 1
answered on 05 Jun 2015, 03:11 AM

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!

0
Alexander Valchev
Telerik team
answered on 08 Jun 2015, 03:13 PM
Hello Saquib,

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Saquib
Top achievements
Rank 1
answered on 08 Jun 2015, 07:27 PM

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!

0
Alexander Valchev
Telerik team
answered on 10 Jun 2015, 04:34 PM
Hello Saquib,

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Saquib
Top achievements
Rank 1
answered on 10 Jun 2015, 08:44 PM

It WORRRKS !!!

 Thank you very much Alexander. You are great.

Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Saquib
Top achievements
Rank 1
Alexander Valchev
Telerik team
Share this question
or