Totaling Columns

1 posts, 0 answers
  1. Mono
    Mono avatar
    7 posts
    Member since:
    Nov 2011

    Posted 03 Dec 2011 Link to this post

    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?
Back to Top