Remove header on GridClientSelectColumn

8 posts, 0 answers
  1. Paul Harahuc
    Paul Harahuc avatar
    3 posts
    Member since:
    Jul 2007

    Posted 27 May 2008 Link to this post

    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.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 May 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Debbie
    Debbie avatar
    27 posts
    Member since:
    Jul 2008

    Posted 20 Aug 2008 Link to this post

    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

  5. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 21 Aug 2008 Link to this post

    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.
  6. Debbie
    Debbie avatar
    27 posts
    Member since:
    Jul 2008

    Posted 21 Aug 2008 Link to this post

    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
  7. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 21 Aug 2008 Link to this post

    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.
  8. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Aug 2008 Link to this post

    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.
  9. Jim
    Jim avatar
    1 posts
    Member since:
    Jun 2007

    Posted 12 May 2015 in reply to Shinu Link to this post

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

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017