I have a RadGrid with a GridClientSelectColumn. I need to enable and disable some buttons on the page, client-side, when certain rows are selected by clicking in the checkbox in each row's GridClientSelectColumn. I added an onclick event to the checkboxes for the required rows and that's all working fine.
My problem is with the select/deselect all checkboxes in the header and footer of the column. Clicking these changes the selection state of all of the rows, and it doesn't fire the onclick event for each of the individual row checkboxes. Which means I need to catch onclick on these, as well, and do some processing to decide whether the buttons should be enabled or disabled.
I didn't have any problem attaching a function to the onclick of the header checkbox:
The function is called, when the checkbox is clicked, and returns true, but none of the row checkboxes are changed. It looks like the selection of all of the individual rows is done in an onclick handler, and I'm replacing it, instead of extending it.
There's probably a real simple way to add another onclick handler without eliminating an existing one. Any ideas?
My problem is with the select/deselect all checkboxes in the header and footer of the column. Clicking these changes the selection state of all of the rows, and it doesn't fire the onclick event for each of the individual row checkboxes. Which means I need to catch onclick on these, as well, and do some processing to decide whether the buttons should be enabled or disabled.
I didn't have any problem attaching a function to the onclick of the header checkbox:
protected
void
grd_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridHeaderItem)
{
GridHeaderItem header = (GridHeaderItem)e.Item;
TableCell selectBoxCell = header[
"ClientSelectColumn"
];
Control selectBoxControl = selectBoxCell.Controls[0];
CheckBox selectBox = selectBoxControl
as
CheckBox;
selectBox.Attributes[
"onclick"
] =
"return selectall_clicked(this);"
;
}
}
The function is called, when the checkbox is clicked, and returns true, but none of the row checkboxes are changed. It looks like the selection of all of the individual rows is done in an onclick handler, and I'm replacing it, instead of extending it.
There's probably a real simple way to add another onclick handler without eliminating an existing one. Any ideas?