public class CustomAggregate : ISummaryAggregate
{
public CustomAggregate()
{
}
public double totalSum { get; set; }
public Action<System.Collections.IEnumerable, string, System.ComponentModel.PropertyDescriptor> CalculateAggregateFunc()
{
return (items, property, pd) =>
{
var enumerableItems = items as IEnumerable<OrderInfo>;
if (pd.Name == "totalSum")
{
this.totalSum = enumerableItems.totalSum<OrderInfo>(q=>q.Incurred+q.Paid+q.Reserves);
}
};
}
}
public static class LinqExtensions
{
public static double totalSum<T>(this IEnumerable<T> values, Func<T, double?> selector)
{
double sum = 0;
var count = values.Count();
foreach (var v in values )
{
OrderInfo a = v as OrderInfo;
sum = sum +a.Paid+a.Incurred+a.Reserves;
}
return sum;
}
}
|
We have also prepared a sample based on this and you can download the same from the below location.
Sample Link: http://www.syncfusion.com/downloads/support/forum/129931/ze/SummaryDemo-847017427
Regards,
Sivaraman