This is a migrated thread and some comments may be shown as answers.

Remove header on GridClientSelectColumn

7 Answers 619 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul Harahuc
Top achievements
Rank 1
Paul Harahuc asked on 27 May 2008, 04:32 PM
I wish to have AllowMultiRowSelection="True" yet not include a Select/Deselect All checkbox in the header. Is there an easy way to do this?

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

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 May 2008, 04:19 AM
Hi Paul,

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.
0
Debbie
Top achievements
Rank 1
answered on 20 Aug 2008, 01:46 PM

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

0
Konstantin Petkov
Telerik team
answered on 21 Aug 2008, 10:38 AM
Hello 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.
0
Debbie
Top achievements
Rank 1
answered on 21 Aug 2008, 12:50 PM
Yes, it is in the itemdatabound event since that is what the original post had suggested. So it if doesn't belong there, where would this code need to run.

I need the multi row selection, I just don't want the checkbox in the header (for the 'check all' ability).

Thanks!
Debbie
0
Konstantin Petkov
Telerik team
answered on 21 Aug 2008, 02:21 PM
Hi 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.
0
Shinu
Top achievements
Rank 2
answered on 22 Aug 2008, 05:42 AM
Hi Debbie,

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.
0
Jim
Top achievements
Rank 2
answered on 12 May 2015, 07:07 PM

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;
        } 
    }

Tags
Grid
Asked by
Paul Harahuc
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Debbie
Top achievements
Rank 1
Konstantin Petkov
Telerik team
Jim
Top achievements
Rank 2
Share this question
or