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

GridCheckboxColumn checkboxes don't work

2 Answers 885 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark Galbreath
Top achievements
Rank 2
Mark Galbreath asked on 02 Feb 2010, 09:18 PM
I'm trying to use the RadGrid GridCheckboxColumn for the first time and the checkboxes are inert - they don't work.

<telerik:RadGrid ID="radGrid1" runat="server" Skin="Forest"     AllowFilteringByColumn="True"                           AllowPaging="True"   
    AllowSorting="True"   
    AutoGenerateColumns="False"   
    DataSourceID="ObjectDataSource1"   
    GridLines="None"   
    ShowGroupPanel="True">  
 
    <MasterTableView AllowMultiColumnSorting="True"   
    AutoGenerateColumns="False"   
    DataSourceID="ObjectDataSource1"   
    ShowFooter="True">  
          
        <RowIndicatorColumn> 
        <HeaderStyle Width="20px"></HeaderStyle> 
    </RowIndicatorColumn> 
 
    <ExpandCollapseColumn> 
        <HeaderStyle Width="20px"></HeaderStyle> 
    </ExpandCollapseColumn> 
      
        <Columns> 
        <telerik:GridCheckBoxColumn UniqueName="chkCol"   
            HeaderText="<center>Get<br/>Details</center>"   
            AllowFiltering="false"   
            AllowSorting="false"   
            Groupable="false">  
        <HeaderStyle Width="40px" ForeColor="#193300" Font-Bold="true" /> 
        </telerik:GridCheckBoxColumn> 
        </Columns> 
etc.... 

I copied this pretty much verbatum from one of the online examples.  I searched this forum without success of finding another case like this.  Does anybody have a clue as to why the checkboxes don't work (won't check)?

Thanks,
Mark

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 03 Feb 2010, 05:24 AM

Hello Mark,

By default for a GridCheckBoxColumn, when the grid is in browser mode the checkbox is disabled but when the column is editable, the checkbox is enabled. Check out the following document to understand better about the various columns supported by RadGrid:

Column types


You could still try out the following code to enable the checkboxes in the GridCheckBoxColumn, when the grid is in browser mode.
c#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            CheckBox chk = (CheckBox)item["chkCol"].Controls[0]; 
            chk.Enabled = true
        } 
    } 

Also another suggestion would be to use a GridTemplateColumn with CheckBox in its ItemTemplate as shown below:
aspx:

<telerik:GridTemplateColumn UniqueName="TempCol1"  HeaderText="TempCol1"  >  
   <ItemTemplate>  
       <asp:CheckBox ID="CheckBox1" runat="server"/>  
   </ItemTemplate>  
   <EditItemTemplate> 
       <asp:CheckBox ID="CheckBox2" runat="server" /> 
   </EditItemTemplate> 
</telerik:GridTemplateColumn>  

Thanks
Princy.

0
Mark Galbreath
Top achievements
Rank 2
answered on 03 Feb 2010, 12:52 PM
Excellent response, Princy!  Thank you!  I was going to try the template option today if I could not get the checkbox column to work.  Now I will try both just for kicks.

Cheers!
Mark
Tags
Grid
Asked by
Mark Galbreath
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Mark Galbreath
Top achievements
Rank 2
Share this question
or