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

Aggregate Function Result FormatString Issue

1 Answer 263 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 26 Apr 2021, 11:52 AM

Hello,

Issue when adding columns and aggregate functions programmatically. Version 2019.2

The Group Footer aggregate function works as expected, but when I try to add formatting, it fails.

e.g. if the sum total is 100, the value in the footer appears as "N"

I've tried different format strings - always the same result - what am I doing wrong ?

var c = new GridViewDataColumn
                {
                    Header = columnField.ColumnHeader,
                    MinWidth = 100,
                    DataMemberBinding = new Binding(columnField.ColumnName) { StringFormat = columnField.FormatString },
                    UniqueName = columnField.ColumnName
                };

var sumFunction = new SumFunction() { SourceFieldType = Type.GetType("System.Decimal"), ResultFormatString="N" };

c.AggregateFunctions.Add(sumFunction);

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dilyan Traykov
Telerik team
answered on 29 Apr 2021, 09:33 AM

Hello,

Thank you for the provided code snippet.

To achieve the desired result, the ResultFormatString needs to be in the format "{0:N}":

var sumFunction = new SumFunction() { SourceFieldType = Type.GetType("System.Decimal"), ResultFormatString = "{0:N}" };

For your convenience, I'm also attaching a small sample project which demonstrates this in action.

Please give this a try and let me know if you're able to achieve the expected formatting.

Regards,
Dilyan Traykov
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.

Tags
GridView
Asked by
n/a
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or