Completed
Last Updated: 25 Jan 2013 03:50 by ADMIN
ADMIN
Ivan Todorov
Created on: 25 Jan 2013 03:50
Category: GridView
Type: Bug Report
1
FIX. RadGridView - the Average aggregate function returns incorrect integer result when applied over an integer column.
If the Average aggregate is applied over a column which contains only integer data (for example over the ID column of a DataTable), the result will be calculated as an integer value which is not correct in most cases. To workaround the issue, add a custom evaluation of the average function on the GroupSummaryEvaluate event:

        void radGridView1_GroupSummaryEvaluate(object sender, GroupSummaryEvaluationEventArgs e)
        {
            if (e.SummaryItem.FieldName == "ID" && e.SummaryItem.Aggregate == GridAggregateFunction.Avg)
            {
                int count = 0;
                decimal sum = 0;
                foreach (GridViewRowInfo row in this.radGridView1.Rows)
                {
                    count++;
                    sum += (decimal)row.Cells["ID"].Value;
                }

                e.Value = count > 0 ? sum / count : 0;
            }
        }
0 comments