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

Totaling Columns

0 Answers 77 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mono
Top achievements
Rank 1
Mono asked on 03 Dec 2011, 02:41 PM
Hello,

I have a basic RadGridView setup in my application. The grid will have 6 columns and a variable amount of items. The first five columns just display numeric values. The last column is a total of the entries in the item. The last row is an aggregate of the values in the column. My problem is, I want a grand total to appear in the last column. However, I'm not sure how to do this. Currently, I have defined the following columns:

<telerik:GridViewDataColumn Header="Column1" DataMemberBinding="{Binding Path=Tally[0]}"
  <telerik:GridViewDataColumn.AggregateFunctions>
    <telerik:SumFunction ResultFormatString="{}{0:N2}" SourceField="Tally[0]" />
  </telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
 
<telerik:GridViewDataColumn Header="Column2" DataMemberBinding="{Binding Path=Tally[1]}">
  <telerik:GridViewDataColumn.AggregateFunctions>
    <telerik:SumFunction ResultFormatString="{}{0:N2}" SourceField="Tally[1]" />   
  </telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
 
<telerik:GridViewDataColumn Header="Column3" DataMemberBinding="{Binding Path=Tally[2]}"
  <telerik:GridViewDataColumn.AggregateFunctions>
    <telerik:SumFunction ResultFormatString="{}{0:N2}" SourceField="Tally[2]" /> 
  </telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
 
<telerik:GridViewExpressionColumn x:Name="totalColumn" Header="Total" UniqueName="Total"
  DataFormatString="{}{0:N2}" Expression="Tally[0]+Tally[1]+Tally[2]">
  <telerik:GridViewDataColumn.AggregateFunctions>
    <telerik:SumFunction ResultFormatString="{}{0:N2}" />
  </telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewExpressionColumn>

In the last GridViewExpressionColumn, if I do not put a SourceField in the SumFunction, the application crashes. However, I'm not sure what to put in the SourceField to display the total of all of the entries in the Total column. What am I doing wrong?

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Mono
Top achievements
Rank 1
Share this question
or