In addition, I have a GridHyperlinkColumn in the row that the user may click on to open another window. When this happens, the Row becomes selected (the checkbox becomes checked). I would like this NOT to happen. It there a way to prevent this?
Thanks.
7 Answers, 1 is accepted
Try the following code snippet to hide the HeaderCheckbox in the ClientSelectColumn.
ASPX:
<telerik:GridClientSelectColumn UniqueName="Select" ></telerik:GridClientSelectColumn> |
CS:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridHeaderItem) |
{ |
GridHeaderItem header = (GridHeaderItem)e.Item; |
CheckBox chkbx=(CheckBox)header["Select"].Controls[0]; |
chkbx.Visible=false; |
} |
} |
Thanks
Shinu.
I needed to do the same thing, but when I tried to implement the suggestion I get an error....
Cannoe find a cell bound to column name 'SelectCol'
my ASPX..
<telerik:GridClientSelectColumn HeaderStyle-Width="25px" UniqueName="SelectCol" />
my CodeBehind...
protected
void gridTransferredOpenItems_DataBound(object sender, GridItemEventArgs e)
{
GridItem row = e.Item;
switch (row.ItemType)
{
case GridItemType.Header:
GridHeaderItem header = (GridHeaderItem)row;
CheckBox chkbx = (CheckBox)header["SelectCol"].Controls[0];
chkbx.Visible = false;
break;
default:
break;
}
}
It fails on the line that I've underlined.
Any help would be appreciated.
Thanks!
Debbie
Is that the DataBound or ItemDataBound controls which your handler is attached on? The code below would throw error if you try to access the item through the arguments inside Grid_DataBound event.
Do you need the multi row selection ability or you can exclude that? If you don't need it the header check box will be automatically hidden.
Sincerely yours,
Konstantin Petkov
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I need the multi row selection, I just don't want the checkbox in the header (for the 'check all' ability).
Thanks!
Debbie
The code posted in this thread functions properly on my end hiding the header check box of the Grid ClientSelectColumn. Here is the converted code in VB, would you please give it a try?
If (TypeOf e.Item Is GridHeaderItem) Then |
Dim header As GridHeaderItem = CType(e.Item,GridHeaderItem) |
Dim chkbx As CheckBox = CType(header("Select").Controls(0),CheckBox) |
chkbx.Visible = false |
End If |
If you still need assistance, can you please submit regular support ticket from your Client.NET account where you can send a runnable sample which replicates the error? We will gladly look into the source and get back to you with resolution.
Greetings,
Konstantin Petkov
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Can you try hiding the header checkbox in the Grid PreRender event and see if its working?
CS:
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
foreach (GridHeaderItem header in RadGrid1.MasterTableView.GetItems(GridItemType.Header)) |
{ |
CheckBox chkbx = (CheckBox)header["SelectCol"].Controls[0]; |
chkbx.Visible = false; |
} |
} |
Thanks
Shinu.
The code below works for us. We had to treat this as a TableCell, then find the first control within it. After that, we need to "break" out of the loop, otherwise it will fail on any attempts to access header["Chkbox"] , probably because there is only a single checkbox control in the header of this grid. If all else fails, try it.
protected void poGrid_Prerender(object sender, EventArgs e)
{
foreach (GridHeaderItem header in poGrid.MasterTableView.GetItems(GridItemType.Header))
{
TableCell cell = header["Chkbox"] as TableCell;
cell.Controls[0].Visible = false;
break;
}
}