public class CustomAggregate : ISummaryAggregate
{
public CustomAggregate()
{
}
public double DynmaicValue { get; set; }
public Action<System.Collections.IEnumerable, string, PropertyInfo> CalculateAggregateFunc()
{
return (items, property, pd) =>
{
var enumerableItems = items as IEnumerable<DynamicModel>;
var collection = new ObservableCollection<double>();
foreach (var item in enumerableItems)
{
var dict = item.Values.Where(x => x.Key == "OrderID");
foreach (var value in dict)
{
collection.Add(double.Parse(value.Value.ToString()));
}
}
if (pd.Name == "DynmaicValue")
{
this.DynmaicValue = collection.Sum();
}
};
}
}
//Adding Table summary to the row.
GridTableSummaryRow summaryRow = new GridTableSummaryRow();
summaryRow.Title = "Toal : {TableSummary}";
summaryRow.Position = Position.Top;
summaryRow.ShowSummaryInRow = true;
summaryRow.SummaryColumns.Add(new GridSummaryColumn
{
Name = "TableSummary",
CustomAggregate = new CustomAggregate(),
MappingName = "OrderID",
Format = "{DynmaicValue}",
SummaryType = Syncfusion.Data.SummaryType.Custom
});
grid.TableSummaryRows.Add(summaryRow); |