I have a RadGrid with 3 checkbox columns with a checkbox in the header of those 3 columns. I'm trying to check/uncheck only the checkboxes belonging to the column whose header checkbox is checked.
With the code that I have even though I'm checking/unchecking checkbox of only one header, it is checking/unchecking all the checkboxes in all the 3 columns
How do I change my code to check/uncheck only the checkboxes belonging to the header checkbox that has been checked/unchecked?
Appreciate your help!
With the code that I have even though I'm checking/unchecking checkbox of only one header, it is checking/unchecking all the checkboxes in all the 3 columns
How do I change my code to check/uncheck only the checkboxes belonging to the header checkbox that has been checked/unchecked?
Appreciate your help!
var gridToCheckAll = '<%= rgrdTrips.ClientID %>';
function checkAllRows(sender) {
var checked = sender.checked;
var container = document.getElementById(gridToCheckAll);
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;
}
}
<telerik:RadGrid
ID
=
"rgrdTrips"
runat
=
"server"
AutoGenerateColumns
=
"true"
AllowPaging
=
"false"
AllowMultiRowSelection
=
"true"
AllowSorting
=
"true"
>
<
MasterTableView
CommandItemDisplay
=
"TopAndBottom"
DataKeyNames
=
"Trip_ID"
>
<
Columns
>
<
telerik:GridTemplateColumn
HeaderText="<input
type
=
'checkbox'
id
=
'checkAll'
onclick
=
'checkAllRows(this);'
>"
HeaderStyle-Width="50px" UniqueName="Select">
<
HeaderTemplate
>
<
asp:CheckBox
ID
=
"checkAll"
runat
=
"server"
onclick
=
"checkAllRows(this);"
/>
</
HeaderTemplate
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"cboxSelect"
runat
=
"server"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<%-- <
telerik:GridClientSelectColumn
UniqueName
=
"ClientSelectColumn1"
>
</
telerik:GridClientSelectColumn
>--%>
<
telerik:GridTemplateColumn
HeaderText="<input
type
=
'checkbox'
id
=
'ResAvail'
onclick
=
'checkAllRows(this);'
>"
HeaderStyle-Width="50px" UniqueName="ResourceAvailable">
<
HeaderTemplate
>
<
asp:CheckBox
ID
=
"ResAvail"
runat
=
"server"
onclick
=
"checkAllRows(this);"
/>
</
HeaderTemplate
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"cboxResAvailSelect"
runat
=
"server"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderStyle-Width
=
"50px"
UniqueName
=
"RequestHelp"
>
<
HeaderTemplate
>
<
asp:CheckBox
ID
=
"RqstHelp"
runat
=
"server"
onclick
=
"checkAllRows(this);"
/>
</
HeaderTemplate
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"cboxRqstHelpSelect"
runat
=
"server"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
CommandItemTemplate
>
<
asp:Button
ID
=
"btnExportAll"
runat
=
"server"
Text
=
"Export All"
OnClientClick
=
"showModalPopup('Are you sure you want to export all the trips?'); return false;"
/>
<
asp:Button
ID
=
"btnExportSelected"
runat
=
"server"
Text
=
"Export Selected"
OnClick
=
"ExportSelectedTrips"
/>
</
CommandItemTemplate
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"true"
></
Selecting
>
</
ClientSettings
>
</
telerik:RadGrid
>