下面是我的telerik嵌套网格代码:
<telerik:RadGrid runat="server" ID="OrdersGrid" ShowFooter="True" AllowSorting="True"
EnableLinqExpressions="false" GridLines="None" OnInsertCommand="OrdersGrid_InsertCommand"
OnItemCommand="OrdersGrid_ItemCommand" OnItemDataBound="OrdersGrid_ItemDataBound"
Width="100%" HeaderStyle-CssClass="gridHeader" OnItemCreated="OrdersGrid_ItemCreated">
<ClientSettings>
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView ShowHeader="true" AutoGenerateColumns="False" PageSize="7" HierarchyLoadMode="Client"
Font-Names="Verdana" Font-Size="12px" DataKeyNames="RIGHT_ID">
<NestedViewTemplate>
<telerik:RadGrid ID="brnchgrid" runat="server" OnItemDataBound="brnchgrid_ItemDataBound"
CssClass="gridHeader" Width="100%">
<MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="false" Font-Names="Verdana"
Font-Size="12px">
<Columns>
<telerik:GridBoundColumn HeaderText="Branch CODE" DataField="BRNCH_CODE" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Branch name" DataField="BRNCH_NAME" UniqueName="BRNCH_NAME">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="add" HeaderText="ADD" HeaderStyle-Width="50px">
<ItemTemplate>
<asp:CheckBox ID="chkadd" runat="server" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="50px" />
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="50px" />
</telerik:GridTemplateColumn>
我想提供一个选项,检查 brnchgrid 内嵌套网格中的标题。复选框列名为添加。
答案 0 :(得分:0)
在您的标记中设置标题文字以包含checkbox
,该onclick
调用函数来检查所有复选框<telerik:GridTemplateColumn UniqueName="add" HeaderText="<input type='checkbox' id='checkAll' onclick='checkAll(this, gridToCheckAll);'>" HeaderStyle-Width="50px">
。
<script>
var gridToCheckAll = '<%= brnchgrid.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>
然后在javascript中
{{1}}