我知道我的代码是正确的,但我是否缺少一些脚本,因为 Telerik MVC 网格“检查所有复选框”不起作用?我正在使用 jquery-1.7.1.min.js
@(Html.Telerik().Grid<RenanNewTask.Models.RenanListViewModel>()
.Name("RenanGrid")
.DataKeys(dataKeys => dataKeys.Add(c => c.Org_UID))
.Columns(columns =>
{
//columns.Bound(c => c.eff_date).Title("Effective Date").Format("{0:MM/dd /yyyy}").Width(20);
columns.Bound(c => c.eff_date).Title("Effective Date").ReadOnly(true).Format("{0:MM/dd/yyyy}").Width(20).Encoded(true)
.ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= eff_date #>' />")
.HeaderTemplate(
@<text>
<input type="checkbox" title="check all records" id="checkAllRecords" />
</text>
)
.Title("")
.Width(10)
.HeaderHtmlAttributes(new { style = "text-align:center" })
.HtmlAttributes(new { style = "text-align:center" });
columns.Bound(o => o.eff_date).Width(20);
columns.Bound(c => c.name_long).Title("Name Long").Width(20);
})
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("GetOrgUID", "Renan"))
.Pageable(paging => paging.Style((GridPagerStyles.PageInput | GridPagerStyles.Numeric | GridPagerStyles.PageSizeDropDown | GridPagerStyles.NextPrevious)).Position(GridPagerPosition.Bottom).PageTo(1).PageSize(20))
.Scrollable(scrolling => scrolling.Height(250))
.Resizable(resizing => resizing.Columns(true))
)
脚本:
<script type="text/javascript" lanuage="javascript">
$('#checkAllRecords').click(function checkAll() {
$("#RenanGrid tbody input:checkbox").attr("checked", this.checked);
});
</script>