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

Show certain Group Aggregate depending on groupings

1 Answer 124 Views
GridView
This is a migrated thread and some comments may be shown as answers.
n/a
Top achievements
Rank 1
n/a asked on 06 Dec 2018, 04:31 PM

Is there a way of changing what group headers are shown depending on which columns have been grouped? 

I have a small banking application which displays a breakdown of all fees.

AllFees.PNG shows all of the fees ungrouped

GroupedByDesk.PNG shows the desired behaviour of grouping on any column other than currency (sums all of the rows 'Amount' values exchanged into a single currency)

GroupedByCurrency shows the desired behaviour of grouping by currency alone (sums all of the amounts in that currency)

Where it gets more interesting is if you group by Currency and another column. The desired behaviour is to show ONLY the exchanged sum in the header down in each group, and child group etc., until the Currency grouping, where you ONLY display the currency sum, as demonstrated in GroupByDeskThenCurrency.PNG

I have some working code that prevents the exchanged sum aggregate being displayed (as long as the Currency is the first grouping), but it's still not quite what the desired outcome is. Said code:

private void GridView_Grouped(object sender, Telerik.Windows.Controls.GridViewGroupedEventArgs e)
    {
      foreach (Telerik.Windows.Controls.GridViewColumn col in this.GridView.Columns)
      {
        col.AggregateFunctions.Clear();
      }

      bool groupedByCurrency = false;
      bool addedFxdSumAggregate = false;
      
      foreach (ColumnGroupDescriptor gd in this.GridView.GroupDescriptors)
      {
        if (gd.DisplayContent.ToString() == "Currency")
        {
          groupedByCurrency = true;
          this.GridView.Columns["Currency"].AggregateFunctions.Add(this.currSumFunction);
        }

        if (!groupedByCurrency && !addedFxdSumAggregate)
        {
          this.GridView.Columns[gd.DisplayContent.ToString()].AggregateFunctions.Add(this.fxableSumFunction);
          addedFxdSumAggregate = true;
        }
      }

 

 

 

1 Answer, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 11 Dec 2018, 03:00 PM
Hello Abbie,

Thank you for the provided pictures and sample code.

May I ask you some questions in order to better understand the described scenario? Can you share how the RadGridView and mainly its columns are defined on your end? My current understanding is that you have two aggregate functions defined on two different columns. Feel free to correct me if that is not the case and provide some more information on the matter.

If you find it possible, you can also prepare a sample application demonstrating your scenario and send it in a new support ticket. This way I will be able to better understand the scenario and potentially suggest a feasible approach.
 
I am looking forward to your reply.

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
n/a
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or