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

[Solved] Only One Aggregate Function Displaying

2 Answers 188 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeanne
Top achievements
Rank 2
Jeanne asked on 14 Mar 2009, 03:16 AM
I just purchased this product, and I am trying to find a way to provide sums for several columns of a grid.  I have used Infragistics for a number of years and have been able to create footers that display the sums for columns.  I am trying to replicate that behavior, or at least provide something similar.

Although the data I have does not need grouping, I have put a GroupDescription around one column that is the same for all rows.  Then I have used the following code to get two sums in the group header:
                                    <tdata:RadGroupDescription.AggregateFunctions>
                                        <tdata:SumFunction Name="TotalAcreage" SourceField="SumOfAcreage" Caption="Total Acreage:" />
                                        <tdata:SumFunction Name="TotalUnits" SourceField="SumOfUnits" Caption="Total Units:" />
                                        <tdata:AverageFunction Name="Ave" SourceField="SumOfAcreage" Caption="Average Acres" />
                                    </tdata:RadGroupDescription.AggregateFunctions>
But only the first one of these sums is displayed.  I noticed that someone in the forums had this problem in early 2008.  Your example shows two functions, so it must be possible.  I'm just not sure why mine only shows one.  Any suggestions?

As an alternative, are footer aggregates available for Silverlight?

Thanks,
Jeanne


2 Answers, 1 is accepted

Sort by
0
Jeanne
Top achievements
Rank 2
answered on 15 Mar 2009, 02:25 AM
I found the error.  I was using "Name" instead of "FunctionName". 

Another question: is there a way to format an average so it does not show so many places to the right of the decimal?
0
Hristo Deshev
Telerik team
answered on 17 Mar 2009, 12:05 PM
Hello Jeanne,

Straight to your questions:
  1. The Name property is a problem (a bug in my opinion) with the Silverlight XAML parser. That is why we introduced FunctionName, and that is now the recommended way of configuring your aggregates.
  2. Unfortunately there is no way to display a footer with calculated totals. We are planning on implementing the feature for one of the next releases. Looking at the number of requests, it is likely that we will schedule it for Q2 2009.
  3. There is no easy way to change the data formatting in the aggregate cells. We should be providing a public Style property that will allow you to do that (I've added it to the product backlog). Until that happens, you can find the GridViewAggregateResultCell control instances and force a new template unto them with code like the one below:

    var aggregateCells = aggregateCellsContainer.ChildrenOfType<GridViewAggregateResultCell>(); 
    foreach (var cell in aggregateCells) 
        cell.Template = aggregateCellTemplate; 
     

    The actual template is best defined in XAML and obtained through a resource dictionary.
I am attaching a sample project that demonstrates data formatting with the approach outlined in pt. 3 above.

All the best,
Hristo Deshev
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Jeanne
Top achievements
Rank 2
Answers by
Jeanne
Top achievements
Rank 2
Hristo Deshev
Telerik team
Share this question
or