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

AggregateFunction

6 Answers 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
johanr
Top achievements
Rank 1
johanr asked on 28 Sep 2009, 11:36 AM
CountFunction function = new CountFunction();
function.Caption = "Test Caption:";
group.AggregateFunctions.Add(function);

group is a GroupDescriptor
This does not display on the grid.

How do I create Aggregate functions during runtime?

6 Answers, 1 is accepted

Sort by
0
Ludovic Gerbault
Top achievements
Rank 1
answered on 28 Sep 2009, 01:18 PM
I think you forgot the SourceField, which tells your CountFunction what to count exactly.

Here is a code snippet I use to put an aggregate function on a footer :

                                        SumFunction countFunction = new SumFunction(); 
                                        countFunction.ResultFormatString = "{0:F}"
                                        countFunction.SourceField = r.lib_zone; 
                                        countFunction.Caption = "Total : "
                                        col.AggregateFunctions.Add(countFunction); 
                                     
                                        FormGrille.ShowColumnFooters = true
                                        col.Footer = FormGrille.AggregateResults["countFunction"] ; 

0
johanr
Top achievements
Rank 1
answered on 28 Sep 2009, 02:01 PM
I tried adding the source field but it made no difference.

Edit:
Something i did notice.
If I sort the grouped column afterwards, the results of the function is shown.
This might be a refresh problem perhaps.
Should this happen inside or ourside of a DeferRefresh?
0
Ludovic Gerbault
Top achievements
Rank 1
answered on 28 Sep 2009, 02:15 PM
Quick question before answering, does you scenario require the aggregate function to be done in code instead of doing it in xaml ?
0
johanr
Top achievements
Rank 1
answered on 29 Sep 2009, 06:58 AM
Yes, it becomes part of a save and load process of profiles for our application.
This means that I need to be able to creaet the functions in code as profiles are changed.
Everything else works great, it's just this one last part that is being a bit of a problem.

I have descovered that it does indeed add the function but after adding it the UI is not flushed.
If you perform a action like sorting on a column then all of a sudden the function results are visible.

So it works but not 100%.
This happens outside of a defer refresh because defer refresh does not allow you to create group definitions.

I had a similar UI flush problem with saving column sort information where the column header did not highlight after setting it.
When I put that in a defer refresh, that ui flush came right that is why I am thinking that this might be something similar, but I don't know how to tell the grid to redraw itself

What would be perfect is if you could have something like.

grid.BeginUpdate();
do some stuff like creation of stuff
grid.EndUpdate(); <- this does the refresh work for you.
0
Milan
Telerik team
answered on 30 Sep 2009, 06:18 AM
Hi johanr,

You could try calling RadGridView.Rebind to refresh the UI.

All the best,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Johan Rabie
Top achievements
Rank 1
answered on 30 Sep 2009, 06:47 AM
That certainly did the job.
Thank you very much, I am very chuffed with the results.
Tags
GridView
Asked by
johanr
Top achievements
Rank 1
Answers by
Ludovic Gerbault
Top achievements
Rank 1
johanr
Top achievements
Rank 1
Milan
Telerik team
Johan Rabie
Top achievements
Rank 1
Share this question
or