我从下面的链接中复制了代码 Check all CheckBoxes in Telerik nested Grid in C#
当我运行代码时,我得到了这个错误:
0x800a01b6 - Microsoft JScript runtime error: Object doesn't support this property or method
并且在'checkAll(this, gridToCheckAll);'
带有错误的动态运行代码中突出显示。
任何帮助,将不胜感激。
<script>
var gridToCheckAll = '<%= rgFiles.ClientID %>';
function checkAll(sender, containerID) {
var checked = sender.checked;
var container = document.getElementById(containerID);
var checkboxes = container.getElementsByTagName('input');
for (var i = 0, l = checkboxes.length; i < l; i++) {
if (checkboxes[i] != sender && !checkboxes[i].disabled)
checkboxes[i].checked = checked;
}
}
</script>
<telerik:RadGrid id="rgFiles" runat="server" HorizontalAlign="NotSet" BackColor="darkgray"
AllowPaging="True" PageSize="50" AllowSorting="True"
EnableEmbeddedScripts="true"
OnNeedDataSource="rgFiles_NeedDataSource"
OnItemCommand="rgFiles_ItemCommand"
OnItemDataBound="rgFiles_ItemDataBound"
OnItemEvent="rgFiles_ItemEvent"
AllowMultiRowSelection="true" Skin=""
AllowFilteringByColumn="true" EnableLinqExpressions="false" >
<MasterTableView HorizontalAlign="NotSet" AutoGenerateColumns="false" AllowSorting="True"
Font-Size="7pt" AllowCustomSorting="true" CellPadding="2" CellSpacing="1" BorderWidth="0px"
TableLayout="Fixed" AlternatingItemStyle-Wrap="false" ItemStyle-Wrap="false"
CommandItemStyle-Wrap="false" >
<FooterStyle CssClass="datagrid-footerstyle" HorizontalAlign="Right" />
<ItemStyle CssClass="datagrid-itemstyle" Wrap="false" Font-Size="XX-Small" Height="15px"/>
<EditItemStyle BackColor="#2461BF" />
<PagerStyle BackColor="#E0E0E0" ForeColor="DimGray" HorizontalAlign="Left" Mode="NextPrevAndNumeric"
NextPageText="next" PrevPageText="prev" AlwaysVisible="True" />
<HeaderStyle CssClass="datagrid-headerstyle" ForeColor="White" />
<FilterItemStyle BackColor="#a9a9a9" />
<AlternatingItemStyle CssClass="datagrid-alternatingitemstyle" />
<ExpandCollapseColumn Visible="False">
<HeaderStyle Width="19px" />
</ExpandCollapseColumn>
<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<Columns>
<telerik:GridTemplateColumn SortExpression="Reviewed" DataField="Reviewed" HeaderText="<input type='checkbox' id='checkAll' onclick='checkAll(this, gridToCheckAll);'>"
UniqueName="Reviewed" AllowFiltering="false" >
<ItemTemplate>
<asp:CheckBox ID="cbReviewed" runat="server" OnCheckedChanged="cbReviewed_CheckedChanged" />
</ItemTemplate>
<ItemStyle Wrap="False" HorizontalAlign="Center" VerticalAlign="Top"></ItemStyle>
<HeaderStyle Width="50px"></HeaderStyle>
</telerik:GridTemplateColumn>