AggregateFunction result only in Grid's Group Header

1 Answer 51 Views
GridView
Richard
Top achievements
Rank 1
Richard asked on 16 Oct 2023, 11:14 AM

Hi,

I have a RadGridView, and have added a ColumnGroupDescriptor to `RadGridView.GroupDescriptors`. I have also added an AggregateFunction to `GridViewColumn.AggregateFunctions` for several columns.

The aggregateFunction results are displayed in the grid's footer, each group's footer, and each group's header.

I now want to add an aggregateFunction that, only in the group's header, shows how many rows are in the group. I do not want this result to be shown in any footers.

I understand that this second point could be achieved if I had used GroupDescriptor instead of ColumnGroupDescriptor, however I do still want to be able to add other aggregateFunctions to columns and have these results show in both headers and footers.

 

I have currently attempted this by adding a small prefix to the AggregateFunction's "FunctionName", indicating it should only be shown in group headers; and then modified the GridView template to filter AggregateFunctions by this prefix as needed for headers and footers. However, this is not an elegant solution, so I was wondering what you would recommend.

Thanks, Richard

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 18 Oct 2023, 10:28 AM

Hello Richard,

RadGridView doesn't have any API that allows the desired behavior automatically. To achieve that you can customize the corresponding templates, as you are already doing. An alternative idea is to use an attached that replaces the underlying data source with the AggregateResult objects. You can find this approach in the attached project. I hope that helps.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Richard
Top achievements
Rank 1
commented on 24 Oct 2023, 08:27 AM

Thanks for the alternative solution, Martin.
Tags
GridView
Asked by
Richard
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or