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

Unwanted Doubling From AggregateFunctions

2 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Arne
Top achievements
Rank 1
Arne asked on 24 Aug 2011, 04:36 PM
Hello,

for our program we use the MVVM-Pattern, so we have some "bindable propertiers". Such like the GroupDescriptorCollection (named DefaultGroupDesciptors) for the GridViews in our forms.

protected override void InitGroups()
{
   DefaultGroupDescriptors = new GroupDescriptorCollection();
 
   GroupDescriptor Descriptor_STKNR = new GroupDescriptor();
   Descriptor_STKNR.Member = "Field1";
   CountFunction cound = new CountFunction();
   Descriptor_STKNR.AggregateFunctions.Add(cound);
   DefaultGroupDescriptors.Add(Descriptor_STKNR);
 
   GroupDescriptor Descriptor_MEAUF = new GroupDescriptor();
   Descriptor_MEAUF.Member ="Field2";
   SumFunction sum = new SumFunction();
   Descriptor_MEAUF.AggregateFunctions.Add(sum);
   DefaultGroupDescriptors.Add(Descriptor_MEAUF);
}


// execut at the binding:
foreach
(GroupDescriptor Elem in DefaultGroupDescriptors)

{
  
     Grid.GroupDescriptors.Add(Elem);

    AddAggregateFunctions(Grid, Elem); 
}

 
private static void AddAggregateFunctions(RadGridView Grid, GroupDescriptor Elem)
{
   if (Elem.AggregateFunctions != null)
   {
      foreach (AggregateFunction Function in Elem.AggregateFunctions)
      {
         Grid.Columns[Elem.Member].AggregateFunctions.Add(Function);
      }
   }
}

The important part:
    Grid.GroupDescriptors.Add(Elem);
    AddAggregateFunctions(Grid, Elem);


This part doubles the AggregateFunctions from the first element:
(
         ...
   CountFunction cound = new CountFunction();
   Descriptor_STKNR.AggregateFunctions.Add(cound);
   DefaultGroupDescriptors.Add(Descriptor_STKNR);
    ...
)

to the seond element
(
    ...
 DefaultGroupDescriptors.Add(Descriptor_MEAUF);
    ...
).

I think a picture is helpful:



If I rotate the "important part", it works...

foreach (GroupDescriptor Elem in newValue)
{
   AddAggregateFunctions(ActGrid, Elem);
   ActGrid.GroupDescriptors.Add(Elem);
}


I hope you can explain me what happens here...

Regards
Arne Z.

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 30 Aug 2011, 02:25 PM
Hello Arne,

We will need some more time to investigate the issue. In the mean time may you clarify what is the exact scenario that you want to accomplish ? Does changing the order of the two lines ruin the logic of you application ?
 

Regards,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Arne
Top achievements
Rank 1
answered on 30 Aug 2011, 03:41 PM
Hello Maya,

the problem is solved!
There was another binding that add the AggregateFunctions to the column.
Sometimes it's hard to keep track of these by using the MVVM-Pattern.

The AddAggregateFunctions added all AggregateFunctions to the spezified group-coloum. So it seems that the Functions are doubled.

Sorry for the unneeded work.


Reagrds,
Arne Z.
Tags
GridView
Asked by
Arne
Top achievements
Rank 1
Answers by
Maya
Telerik team
Arne
Top achievements
Rank 1
Share this question
or