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

Default FooterText when empty

2 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
IT
Top achievements
Rank 2
IT asked on 03 Jun 2010, 05:35 PM
Is there a way to set a default FooterText for when the grid is empty (other than writing a custom one)?  I want the footer to show "Total Amount: $0.00", but it displays "Total Amount: "

<telerik:GridBoundColumn   
   DataField="Amount"   
   DataType="System.Double" 
   HeaderText="Amount"   
   ReadOnly="True"   
   SortExpression="Amount"   
   UniqueName="Amount"   
   Aggregate="Sum"   
   ItemStyle-Wrap="false"   
   FooterAggregateFormatString="Total Amount: {0:C}">  
</telerik:GridBoundColumn> 
 

 

 

 

Adding an attribute of FooterText="Total Amount: 0" still displays "Total Amount: "

Thanks!

 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 04 Jun 2010, 08:02 AM
Hello Sundance,

You can set the default FooterText when the grid is empty, by checking the DataItem count explicitly and accessing the footer cells using the ColumnUniqueNames of the corresponding columns.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
      if (e.Item is GridFooterItem) 
        { 
            GridFooterItem footer = (GridFooterItem)e.Item; 
            if (RadGrid1.MasterTableView.Items.Count == 0) 
            { 
                footer["Amount"].Text = "Total Amount: $0.00"
            } 
        } 
    } 

Regards,
Shinu.
0
IT
Top achievements
Rank 2
answered on 07 Jun 2010, 01:42 PM
Thanks, Shinu!

(I was hoping that there was an attribute that I could set for when the grid is empty.)
Tags
Grid
Asked by
IT
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
IT
Top achievements
Rank 2
Share this question
or