Ludovic Gerbault
Top achievements
Rank 1
Ludovic Gerbault
asked on 01 Sep 2009, 08:51 AM
Hello,
I'd like to create a footer on some of my columns that would display a sum function that would update each time I add a new row.
But I need to do it completely programmatically.
Here's what I've done so far :
The column is a GridViewDataColumn of type decimal wich is also created in code.
The result I have with this code is that in the columns, it displays in the footer the message "Telerik.Windows.Data.sumfunction"
Anyone knows how that would work ?
I'd like to create a footer on some of my columns that would display a sum function that would update each time I add a new row.
But I need to do it completely programmatically.
Here's what I've done so far :
if (r.grille.Contains("Ecriture")) |
{ |
SumFunction countFunction = new SumFunction(); |
countFunction.ResultFormatString = "{0:F}"; |
countFunction.SourceField = r.lib_zone; |
countFunction.Caption = "Total : "; |
FormGrille.ShowColumnFooters = true; |
col.Footer = countFunction ; |
} |
The column is a GridViewDataColumn of type decimal wich is also created in code.
The result I have with this code is that in the columns, it displays in the footer the message "Telerik.Windows.Data.sumfunction"
Anyone knows how that would work ?
7 Answers, 1 is accepted
0
Hi,
You should add the result from the function in the footer not the function itself. You can add the function in AggregateFunctions column property.
Kind regards,
Vlad
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.
You should add the result from the function in the footer not the function itself. You can add the function in AggregateFunctions column property.
Kind regards,
Vlad
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
Ludovic Gerbault
Top achievements
Rank 1
answered on 01 Sep 2009, 09:27 AM
Ok, but what property of my countFunction corresponds to the result of the function exactly ?
0
Ludovic Gerbault
Top achievements
Rank 1
answered on 01 Sep 2009, 10:19 AM
Bonus Question :
How do I update my footer when I add a new row in my RadGridView that changes the result of the aggregateFunction ?
How do I update my footer when I add a new row in my RadGridView that changes the result of the aggregateFunction ?
0
Hello,
I've attached small example to illustrate you how to achieve this. As to the new records the grid will rebind itself and will recalculate aggregates automatically.
All the best,
Vlad
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.
I've attached small example to illustrate you how to achieve this. As to the new records the grid will rebind itself and will recalculate aggregates automatically.
All the best,
Vlad
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
Inquisitor Jax
Top achievements
Rank 1
answered on 08 Sep 2009, 01:38 PM
Vlad,
In your sample, I replaced the CountFunction() with new SumFunction(), but get a InvalidOperationException:
"No method 'Sum' on type 'System.Linq.Enumerable' is compatible with the supplied arguments."
Is there something additional to be added when creating a SumFunction from code?
In your sample, I replaced the CountFunction() with new SumFunction(), but get a InvalidOperationException:
"No method 'Sum' on type 'System.Linq.Enumerable' is compatible with the supplied arguments."
Is there something additional to be added when creating a SumFunction from code?
0
Inquisitor Jax
Top achievements
Rank 1
answered on 08 Sep 2009, 01:39 PM
Also, could you expand the example by showing how to programmatically add group footers?
EDIT: k - found answer to this one:
Handle the Grid_Grouping event, and then add a function to the e.Descriptor
...something like:
EDIT: k - found answer to this one:
Handle the Grid_Grouping event, and then add a function to the e.Descriptor
...something like:
private void RadGridView1_Grouping(object sender, Telerik.Windows.Controls.GridView.GridView.GridViewGroupingEventArgs e) |
{ |
//only add group footer if column = "Age", and it is being grouped (ie: group is added, not removed) |
if (e.GroupDescriptor.Member == "Age" && e.Action == CollectionChangeAction.Add) |
{ |
e.GroupDescriptor.AggregateFunctions.Add(_countFunction); |
} |
} |
0
Hello,
You need to set SourceField for SumFunction.
Kind regards,
Vlad
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.
You need to set SourceField for SumFunction.
Kind regards,
Vlad
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.