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

Column group aggregates don't show for custom group descriptor

2 Answers 203 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dom
Top achievements
Rank 1
Dom asked on 08 Nov 2019, 02:24 PM

Hi,

I've been using custom Group Descriptors on my RadGridView so I can specify the order the groups are sorted into however on these custom groups, (an example of how I create the descriptor is below), the column aggregates do not show. But if I do not override the group descriptor the column aggregates show on the row groups correctly. Is it possible for me to show these aggregate values on my custom groups?

Thanks for your help!!

01.private GroupDescriptor<PnlPosition, string, DateTime> GetInstrumentIdGroupDescriptor(ListSortDirection dir)
02.        {
03.            var descriptor = new GroupDescriptor<PnlPosition, string, DateTime>
04.            {
05.                GroupingExpression = o => o.InstrumentId.ToString(),
06.                GroupSortingExpression = group => group.ElementAt(0).Expiry.Value,
07.                SortDirection = dir,
08.                DisplayContent = "InstrumentId",
09.            };
10.            return descriptor;
11.        }
12. 
13.        private void PositionResultsGridView_Grouping(object sender, Telerik.Windows.Controls.GridViewGroupingEventArgs e)
14.        {
15.            if (e.Action == GroupingEventAction.Place)
16.            {               
17.                var columnGroup = e.GroupDescriptor as ColumnGroupDescriptor;
18.                if (columnGroup != null && columnGroup.Column.UniqueName == "InstrumentId")
19.                {
20.                    // cancel the default grouping
21.                    e.Cancel = true;
22.                    var descriptor = GetInstrumentIdGroupDescriptor(e.GroupDescriptor.SortDirection ?? ListSortDirection.Descending);
23.                     
24.                    //descriptor.AggregateFunctions = columnGroup.A
25.                    // add the new descriptor
26.                    ((RadGridView)sender).GroupDescriptors.Add(descriptor);
27.                }
28.                else if (columnGroup != null && columnGroup.Column.UniqueName == "Underlying")
29.                {
30.                    // cancel the default grouping
31.                    e.Cancel = true;
32.                    // add the new descriptor
33.                    var descriptor = GetUnderlyingGroupDescriptor(e.GroupDescriptor.SortDirection ?? ListSortDirection.Descending);
34.                    ((RadGridView)sender).GroupDescriptors.Add(descriptor);
35.                }
36.            }
37.        }

 

 

2 Answers, 1 is accepted

Sort by
0
Dom
Top achievements
Rank 1
answered on 13 Nov 2019, 09:56 AM
Any help would be really appreciated :D 
0
Vladimir Stoyanov
Telerik team
answered on 13 Nov 2019, 12:27 PM

Hello Dom,

Thank you for the provided picture and sample code. 

When an aggregate function is defined for a column, it will be displayed on creating a ColumnGroupDescriptor. This happens when the RadGridView is grouped from the UI. In your scenario, I can suggest utilizing the AggregateFunctions property of the GroupDescriptor. 

I am attaching a sample project to demonstrate what I have in mind. Please, check it out and let me know, if you find it helpful. 

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Dom
Top achievements
Rank 1
Answers by
Dom
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Share this question
or