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

Extra column header multi-col span

1 Answer 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anne Chinn
Top achievements
Rank 1
Anne Chinn asked on 04 Nov 2008, 08:10 PM
I would like to be able to have an additional column header that spans multiple columns so that the multiple columns are under a column heading.  I saw another post about how to use the GridTemplateColumn/HeaderTemplate/ItemTemplate to achieve this, but I don't see how this will work when I have field values that are of type GridCheckBoxColumn and still be able to get an automatic editmode to come up.

Thanks,

Anne

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Nov 2008, 06:44 AM
Hello Anne,

Check out the code below which I implemented to achieve a similar scenario. Here, I replace the CheckBoxColumn with a TemplateColumn and disable the checkbox in normal mode of the grid so that it behaves as a checkbox column.
aspx:
  <telerik:GridTemplateColumn UniqueName="TemplateColumn3"
       <HeaderTemplate> 
        <table cellspacing="1"  cellpadding="1" width="300" border="1"
        <tr> 
        <td width="50%"><b>Products</b></td>           
        </tr> 
        <tr> 
        <td width="50%"
          ProductName 
        </td> 
        <td colspan="2" align="right"
         SoldOut 
        </td> 
        </tr> 
        </table> 
       </HeaderTemplate> 
       <ItemTemplate> 
        <table  cellspacing="1"  cellpadding="1" width="300" border="1">        
        <tr> 
        <td width="50%"
           <asp:Label ID="Label1" runat="server" Text='<%#Eval("FirstName") %>' ></asp:Label> 
        </td> 
        <td width="50%"
        <asp:CheckBox ID="CheckBox1" Checked='<%#Eval("Check") %>' runat="server" /> 
        </td> 
        </tr> 
        </table>         
       </ItemTemplate>    
       <EditItemTemplate> 
         <table cellspacing="1"  cellpadding="1" width="300" border="1">         
         <tr> 
         <td width="50%"
            <asp:TextBox ID="TextBox2" Text='<%#Eval("FirstName") %>' runat="server"></asp:TextBox> 
         </td> 
         <td width="50%"
           <asp:CheckBox ID="CheckBox" runat="server" /> 
         </td> 
        </tr> 
        </table> 
      </EditItemTemplate>         
   </telerik:GridTemplateColumn>   
 <telerik:GridTemplateColumn> 

cs:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            CheckBox check = (CheckBox)item.FindControl("CheckBox1"); 
            check.Enabled = false
          
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Anne Chinn
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or