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>