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

Footer questions

1 Answer 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
miksh
Top achievements
Rank 1
Iron
miksh asked on 12 Nov 2008, 09:14 PM
Hi there,

I have two questions regarding to RadGrid footer:

1. Is there a way to create multi-row footer? E.g. in the order footer I need to display order's subtotal, taxes and total on separate rows.

2. How to merge cells in the footer? E.g. there is a grid with 6 columns. I need to display data in the footer in the first and last columns but data length may exceed the column width so I need to merge first 4 cells and last 2 cells to aviod wrapping.

Thanks in advance,
Michael

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 13 Nov 2008, 01:18 PM
Hello Miksh,

You can use a Template Column and customize the FooterTemplate inorder to get multi rows in the footer. Then you will have to remove the other footer item cells and adjust the width of the table in the FooterTemplate to that of the grid. Check out the code below.
aspx:
 <telerik:GridTemplateColumn UniqueName="TemplateColumn3"
        <HeaderTemplate>        
          ProductName        
        </HeaderTemplate> 
        <ItemTemplate>         
           <asp:Label ID="Label1" runat="server" Text='<%#Eval("ProductName") %>' ></asp:Label>         
         
        </ItemTemplate>    
        <EditItemTemplate>        
            <asp:TextBox ID="TextBox2" Text='<%#Eval("ProductName") %>' runat="server"></asp:TextBox>          
        </EditItemTemplate>   
        <FooterTemplate> 
        <%--Adjust the width of the table accordingly--%> 
        <table cellspacing="1"  cellpadding="1"  width="2000" border="1">         
        <tr> 
        <td > 
            <asp:Label ID="Label2" runat="server" Text="CustomText1"></asp:Label>             
         </td> 
         </tr> 
         <tr> 
        <td > 
            <asp:Label ID="Label4" runat="server" Text="CustomText2"></asp:Label>            
         </td> 
         </tr> 
         <tr> 
        <td > 
            <asp:Label ID="Label3" runat="server" Text="CustomText3"></asp:Label>              
         </td> 
         </tr>       
        </table> 
        </FooterTemplate>       
 </telerik:GridTemplateColumn>   

cs:
 
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridFooterItem)   
        {   
            GridFooterItem footer = ((GridFooterItem)e.Item);  
            int index = RadGrid1.Columns.Count;  
            //expand the footer cell according to  the no. of columns 
            footer["TemplateColumn3"].ColumnSpan = index;  
             
            int firstCell = footer.Cells.GetCellIndex(footer["TemplateColumn3"]);  
            while (footer.Cells.Count > firstCell + 1)  
            {  
                // remove the other footer cells 
                footer.Cells.RemoveAt(firstCell + 1);  
            }   
        }   
   }  

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