我使用 Telerik mvc 网格中的复选框。我面临的问题是我的复选框在第一次点击时没有被选中。在第二次单击时,它会被选中,但是在单击另一个复选框时,前一个复选框会被取消选中。我该如何解决这个问题。这是我使用的代码:
@(Html.Telerik().Grid<PermissionMappingModel>()
.Name("mAdministratorpermission-grid")
.DataKeys(keys => keys.Add(m => m.Id))
.Editable(editing => editing.Mode(GridEditMode.InCell))
.ToolBar(commands =>
{
commands.SubmitChanges().ButtonType(GridButtonType.Image).ImageHtmlAttributes(new { style = "margin-left:0" });
})
.Columns(columns =>
{
columns.Bound(x => x.Id).Hidden(true);
columns.Bound(x => x.CategoryName).ReadOnly(true).Width(125);
columns.Bound(x => x.Name).ReadOnly(true).Width(200);
columns.Bound(x => x.IsAllowed)
.ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= IsAllowed #>' />").Width(15).Centered();
})
.DataBinding(
dataBinding => dataBinding.Ajax()
.Select("MAdminCustomerPermissionLoad", "Security")
.Update("MAdminSavePermission", "Security")
)
.Groupable(grouping => grouping.Groups(groups => { groups.Add(c => c.CategoryName); }).Visible(false))
.ClientEvents(events =>
{
events.OnDataBinding("OnMAdminPermissionViewDataBinding");
events.OnSubmitChanges("OnMAdminPermissionSubmit");
events.OnEdit("OnMAdminPermissionEdit");
})
.Sortable()
)