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

update many checkbox

1 Answer 382 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wassim
Top achievements
Rank 1
Veteran
Iron
Wassim asked on 17 Nov 2020, 08:25 AM

I have a gridview with many checkbox rows that i want to update these rows by calling a controller action after clicking a button.
I retrieve correctly the data.

I am using telerik UI in asp.net MVC

  • myView.cshtml

    <div class="form-group">
                                <div class="form-row">
                                    @(Html.Kendo().Grid<mySolution.Models.AutorisationsModel>()
                                                          .Name("gridPerm")
                                                          .Columns(columns =>
                                                          {
                                                              columns.Bound(o => o.Autorisation_ID).Title("id").Hidden();
                                                              columns.Bound(o => o.Module).Title("Module");
                                                              columns.Bound(o => o.Autorisation_READ).Title("Visible").Width(100).ClientTemplate("<input type='checkbox' #= PERM_READ ? checked='checked': '' # class='chkbx' />").HtmlAttributes(new { style = "text-align: center" });
                                                              columns.Bound(o => o.Autorisation_CREATE).Title("Créer").Width(100).ClientTemplate("<input type='checkbox' #= PERM_CREATE ? checked='checked': '' # class='chkbx' />").HtmlAttributes(new { style = "text-align: center" });
                                                              columns.Bound(o => o.Autorisation_DELETE).Title("Supprimer").Width(100).ClientTemplate("<input type='checkbox' #= PERM_DELETE ? checked='checked': '' # class='chkbx' />").HtmlAttributes(new { style = "text-align: center" });
                                                              columns.Bound(o => o.Autorisation_MODIFY).Title("Modifier").Width(100).ClientTemplate("<input type='checkbox' #= PERM_MODIFY ? checked='checked': '' # class='chkbx' />").HtmlAttributes(new { style = "text-align: center" });
                                                              columns.Bound(o => o.Autorisation_LIST).Title("Lister").Width(100).ClientTemplate("<input type='checkbox' #= PERM_LIST ? checked='checked': '' # class='chkbx' />").HtmlAttributes(new { style = "text-align: center" });
                                                          })
                                                          .Editable(editable => editable.Mode(GridEditMode.InCell))
                                                          .DataSource(dataSource => dataSource
                                                              .Ajax()
                                                              .Model(model =>
                                                              {
                                                                  model.Id(m => m.Autorisation_ID);
                                                                  model.Field(m => m.Module).Editable(false);
                                                                  model.Field(m => m.Autorisation_READ).Editable(true);
                                                                  model.Field(m => m.Autorisation_CREATE).Editable(true);
                                                                  model.Field(m => m.Autorisation_DELETE).Editable(true);
                                                                  model.Field(m => m.Autorisation_MODIFY).Editable(true);
                                                                  model.Field(m => m.Autorisation_LIST).Editable(true);
                                                              })
                                                              .Read(read => read.Action("Autorisations_Read", "Autorisations", new { Id = Model.Auto_ID }))
                                                          )
                                                          .Sortable()
                                                          .Scrollable()
                                                          .Height(400)
                                    )

                                </div>
                            </div>

 

<div class="form-group">
                  <div class="form-row">
                           <div class="col-md-12" style="text-align: right;">
                                    <input type="submit" id="confirmEdit" value="Enregister" class="mr-1 mb-1 btn btn-primary" />
                                    @Html.ActionLink("Retour", "Autorisations_List", "Autorisations", null, new { @class = "mr-1 mb-1 btn btn-secondary" })
                              </div>
                  </div>
</div>

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Petar
Telerik team
answered on 18 Nov 2020, 03:46 PM

Hi Wassim,

Based on the provided Grid definition, you should not have any issues with the save of the multiple checkbox values. 

Here is a Knowledge base example that demonstrates how the Grid can be saved from an external button.

Using the approach from the linked example and the sample definition of the datasource methods, demonstrated in this demo, you can define a controller method for data update and trigger this update using the saveChanges method.  

I hope the above approach is clear and will help you implement the desired functionality.

Regards,
Petar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Wassim
Top achievements
Rank 1
Veteran
Iron
Answers by
Petar
Telerik team
Share this question
or