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

Group description

4 Answers 186 Views
GridView
This is a migrated thread and some comments may be shown as answers.
G
Top achievements
Rank 1
G asked on 06 Oct 2010, 05:56 PM
Hi,

Using C#, SL4 and version 2010.2.924.1040 of the RadGridView.

I have a grid with ~20 columns. The majority of these columns have a SumFunction for when they are grouped.

When a certain column is dragged to the Group By panel I want to display 3 of the 20 columns aggregates with text preceeding each value in the Group description. This way our users can see the 3 most pertinent values without having to drill down into the group.

I've gone through all the various samples and other threads\examples but can't work out how to do this.

I take it I need to provide my own template for the group description but I can't then work out how to get the sum of each of the 3 columns into the group header template.

Thanks in advance,

G

4 Answers, 1 is accepted

Sort by
0
G
Top achievements
Rank 1
answered on 08 Oct 2010, 10:53 AM
Should I just raise a support ticket for this?
0
Maya
Telerik team
answered on 12 Oct 2010, 09:37 AM
Hi G,

Firstly, you may create a custom IValueConverter that gets the AggregatesResults and returns only those you need:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{      
    RadObservableCollection<AggregateResult> aggregates = value as RadObservableCollection<AggregateResult>;
    AggregateResultCollection newAggregates = new AggregateResultCollection();
    newAggregates.Add(aggregates[0]);
 
    return newAggregates;      
}

Afterwards, you need to predefine the GroupRowStyle of the grid and bind its AggregateResulsList element to the converter collection of the AggregateResult:
 
<telerik:AggregateResultsList                                                         HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"                                                         
ItemsSource="{Binding AggregateResults, Converter={StaticResource AggregatesConverter}}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">

I am sending you a sample project illustrating the proposed solution.


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
G
Top achievements
Rank 1
answered on 01 Nov 2010, 06:37 PM
Thanks for the response on this.

I had to park this work for a while but am now back on it.

I need to be able to only show aggregates for columns that are visible in the gridview. In your example (which I've ported into my solution) I get back 34 aggregates but there isn't a property which indicates visibility of the column the aggregate is related to. In this case only 10 columns are visible.

I use the GridViewSettings behaviour but when Groups are added in this behaviour the Aggregates converter isn't being triggered. If I manually remove the grouping and re-add it via drag/drop the aggregates converter is being triggered. Is there a work around to force the aggregates to be recalculated?

Thoughts?

Edit: I've tryed putting this.grid.CalculateAggregates(); after the using (grid.DeferRefresh) block in LoadState of RadGridViewSettings without any success.
0
Maya
Telerik team
answered on 03 Nov 2010, 06:04 PM
Hi G,

In this case you may take a slightly different approach - handle the Grouped event of the grid and remove the aggregates, whose column is not visible:

void playersGrid_Grouped(object sender, Telerik.Windows.Controls.GridViewGroupedEventArgs e)
        {
            aggregatesToRemove = new List<AggregateFunction>();
                             
            foreach (GridViewColumn column in this.playersGrid.Columns)
            {
                if (column.IsVisible == false)
                {
                    foreach (AggregateFunction columnAggregate in column.AggregateFunctions)
                    {
                        aggregatesToRemove.Add(columnAggregate);
                    }                      
                }
            }
             
            foreach (AggregateFunction function in aggregatesToRemove)
            {
                if ((e.GroupDescriptor as GroupDescriptor).AggregateFunctions.Contains(function))
                {
                    (e.GroupDescriptor as GroupDescriptor).AggregateFunctions.Remove(function);
                }
            }
        }

However, we are in the process of improving the concept of grouping pursuing the goal of better performance and functionality. Most probably the first Service Pack of the next release will enable you to achieve the same result out-of-the-box.

 

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
Tags
GridView
Asked by
G
Top achievements
Rank 1
Answers by
G
Top achievements
Rank 1
Maya
Telerik team
Share this question
or