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

No more data displayed when using SumFunction on GridViewExpressionColumn

3 Answers 94 Views
GridView
This is a migrated thread and some comments may be shown as answers.
HDC
Top achievements
Rank 1
HDC asked on 09 May 2011, 07:15 PM
I have defined following grid:
<telerik:RadGridView x:Name="invoiceDetailGrid" 
                                   ItemsSource="{Binding ElementName=invoiceDetailDomainDataSource, Path=DataView}"                                       
                                   AutoGenerateColumns="False" 
                                   IsReadOnly="False"
                                   IsBusy="{Binding IsBusy, ElementName=invoiceDetailDomainDataSource}"                                      
                                   CanUserDeleteRows="True"
                                   ShowInsertRow="True"
                                   ShowColumnFooters="True"
                                   Deleted="CommitInvoiceDetailDeleted"
                                   RowEditEnded="CommitInvoiceDetailRowEditEnded"
                                   BeginningEdit="InvoiceDetailBeginningEdit"
                                   ShowGroupPanel="False"                                                                          
                                   Height="250" Width="550"                                                                                                              
                                   >
  <telerik:RadGridView.Columns>
    <telerik:GridViewDataColumn Header="Description" UniqueName="Description" Width="250" IsReadOnly="False"></telerik:GridViewDataColumn>
    <telerik:GridViewMaskedTextBoxColumn Header="Price" UniqueName="Price" Width="80" IsReadOnly="False" MaskType="Numeric" Mask="g"  ></telerik:GridViewMaskedTextBoxColumn>
    <telerik:GridViewMaskedTextBoxColumn Header="Quantity" UniqueName="Quantity" Width="80" IsReadOnly="False" MaskType="Numeric" Mask="g" ></telerik:GridViewMaskedTextBoxColumn>
    <telerik:GridViewExpressionColumn Header="Total" UniqueName="Total" Width="120" IsReadOnly="True" Expression="Price * Quantity">
      <telerik:GridViewExpressionColumn.AggregateFunctions>
        <telerik:SumFunction Caption="Total:" SourceField="Total" ></telerik:SumFunction>
      </telerik:GridViewExpressionColumn.AggregateFunctions>
    </telerik:GridViewExpressionColumn>
  </telerik:RadGridView.Columns>
</telerik:RadGridView>

When i run the code i have an empty grid (no rows displayed) and the groupfooter is empty.
When i remove the AggregateFunctions tag, the rows are displayed without problem.

What am i missing?

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 10 May 2011, 07:45 AM
Hi peter,

Please take a look at this forum thread for a reference.  

Kind regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
HDC
Top achievements
Rank 1
answered on 10 May 2011, 07:39 PM
Hello Maya,

Thanks for your response, but there is an extra complication. I'm using the grid as part of a raddataform. I have already posted an issue for this on the forum... it does not work to define an expression row using code when i use the gridview on a dataform.

Please see :
http://www.telerik.com/community/forums/silverlight/data-form/grid-inside-dataform---expression-columns-not-working.aspx

I did not receive a solution as such to this, but rather a workarround (using Expression="Price * Quantity")... which i have demonstrated in the initial code of the thread.

I'm wondering why this code doesn't work (even if you don't place the gridview in a raddataform)... it seems like a straight forward and very basic scenario: create a total column and then calculate a summ on that column. This should not require a dozen lines of code in codebehind!


0
Yavor Georgiev
Telerik team
answered on 16 May 2011, 07:36 AM
Hello peter,

 The built-in aggregate functions work with type members (through the SourceField property). If you don't specify a SourceField on the function, the RadGridView will try to infer it from the DataMemberBinding of the column.

 However, as the ExpressionColumn is not a data-bound column, the RadGridView cannot infer a value for the SourceField property of the aggregate function. To remedy this, we have provided the generic AggregateFunction class, which allows you to specify a custom aggregation expression. You can see how it's used in the example attached to the forum thread Maya linked to.

Best wishes,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
HDC
Top achievements
Rank 1
Answers by
Maya
Telerik team
HDC
Top achievements
Rank 1
Yavor Georgiev
Telerik team
Share this question
or