Applying converters to aggregate values?

1 Answer 182 Views
GridView
Jack
Top achievements
Rank 1
Jack asked on 19 Oct 2021, 09:36 AM
Hello,
We have certain columns in our grid that have the option of being displayed as the same as the raw data or using a converter it can be displayed with the values multiplied by 100, when using aggregates on the column however they still return the same result as when they were the raw values, is there a way to do this nicely? Using a converter on the binding for the aggregate result in the RadGridView control template has the desired effect but affects all columns which we don't want.

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 21 Oct 2021, 09:26 AM

Hello Jack,

Depending on the modification you perform in the converter, you can either define a custom Footer for the column or create a custom aggregate function.

I've prepared a small sample project to demonstrate how you can define a custom footer and use the same converter for the FormattedValue property of the aggregate result.

Please have a look and let me know if the same approach would work in your original application.

Regards,
Dilyan Traykov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Jack
Top achievements
Rank 1
commented on 22 Oct 2021, 01:25 PM

Thank you for the help that's let me fix this issue, there is another related issue however and that is that the filtering of the column is also using values different to what is displayed in the grid, I don't suppose it's possible to change that too?
Dilyan Traykov
Telerik team
commented on 25 Oct 2021, 12:46 PM

This behavior has been explained in the following article: Applied IValueConverter on the DataMemberBinding. As suggested, you can use an additional calculated property and then utilize the FilterMemberPath property instead of using the IValueConverter.
Another approach I can suggest based on your concrete scenario is to handle the Filtered event of the control and update the values of the filter descriptor. In the sample project I provided, this can be done as follows:

        private void playersGrid_Filtered(object sender, Telerik.Windows.Controls.GridView.GridViewFilteredEventArgs e)
        {
            if (e.ColumnFilterDescriptor.Column.UniqueName == "Number")
            {
                e.ColumnFilterDescriptor.FieldFilter.Filter1.Value = (int)e.ColumnFilterDescriptor.FieldFilter.Filter1.Value / 100;
            }
        }
Please let me know if a similar approach would work for you.

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