ComponentOne FlexGrid for WPF and Silverlight
Features / Data Aggregation
In This Topic
    Data Aggregation
    In This Topic

    FlexGrid lets you compute and display aggregate value for each group created after grouping data. The control shows groups in a collapsible outline format and automatically displays the number of items in each group. However, you can go one step further and display aggregate values for every grouped column. This feature enables users in drawing out more insights from random data. For instance, a company's sales data grouped by country or product category can be more useful if the aggregate sales can be indicated against each country and product category in the grid itself. The Column class provides the GroupAggregate property that can be set to Aggregate to automatically calculate and display aggregates. The aggregates calculated by setting the GroupAggregate property automatically recalculate the aggregate values when the data changes.

    The following image shows a FlexGrid with aggregate values displayed in the columns.

    Aggregates displayed in columns

    To set aggregate through code

    You can display the aggregate value for each group in FlexGrid by setting the grid's AreGroupHeadersFrozen property to false and then setting the GroupAggregate property on each column to one of the supported aggregate values. Some of the supported aggregate values are Sum, Average, Count, Minimum, Maximum, etc.

    Note: Since the aggregates appear in the group header rows, it is necessary to make them visible by setting the AreGroupHeadersFrozen property to false.

    The following code illustrates displaying totals for the Price, Cost, Weight and Volume columns through XAML.

    Copy Code
    <fg:C1FlexGrid x:Name="_flex" AutoGenerateColumns="False"
        <fg:Column Header="Line" Binding="{Binding Line}" />
        <fg:Column Header="Color" Binding="{Binding Color}" />
        <fg:Column Header="Name" Binding="{Binding Name}" />
        <fg:Column Header="Price" Binding="{Binding Price}"
          Format="n2" HorizontalAlignment="Right" Width="*"
        <fg:Column Header="Cost" Binding="{Binding Cost}"
          Format="n2" HorizontalAlignment="Right" Width="*"
        <fg:Column Header="Weight" Binding="{Binding Weight}"
          Format="n2" HorizontalAlignment="Right" Width="*"
        <fg:Column Header="Volume" Binding="{Binding Volume}"
          Format="n2" HorizontalAlignment="Right" Width="*"
    See Also