I am trying to create extension method for GridBoundColumnBuilder for setting aggregate cell for column and format it. The attempt is in following style (grid_ext_1.png).
My intent is to set dataSource.Aggregates for column to count sum of all items, and ClientFooterTemplate to perform formatting of aggregate cell.
Another intent is to reduce the whole code - as I have already bound property of class to column (in the GridColumnFactory), I do not want to write another method for setting aggregate item (in the DataSourceAggregateDescriptorFactory). I have ~40 columns in one grid and it is really hurts to write method for every column 2 times.
In the case of the attached code I have an exception "Ambigous Match Found". Due to head of stack trace:
in System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
in System.Type.GetProperty(String name)
in Kendo.Mvc.Infrastructure.Implementation.Expressions.GroupDescriptorExpressionBuilder.<>c__DisplayClassc.<CreateProjectionMemberBindings>b__b(AggregateFunction f, Expression e)
in Kendo.Mvc.Extensions.EnumerableExtensions.<ZipIterator>d__7`3.MoveNext()
in System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
in System.Dynamic.Utils.CollectionExtensions.ToReadOnly[T](IEnumerable`1 enumerable)
in System.Linq.Expressions.Expression.MemberInit(NewExpression newExpression, IEnumerable`1 bindings)
in Kendo.Mvc.Infrastructure.Implementation.Expressions.GroupDescriptorExpressionBuilder.CreateProjectionInitExpression()
in Kendo.Mvc.Infrastructure.Implementation.Expressions.GroupDescriptorExpressionBuilder.CreateAggregateFunctionsProjectionMemberBinding()
in Kendo.Mvc.Infrastructure.Implementation.Expressions.QueryableAggregatesExpressionBuilder.<CreateMemberBindings>d__0.MoveNext()
in System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
in System.Dynamic.Utils.CollectionExtensions.ToReadOnly[T](IEnumerable`1 enumerable)
in System.Linq.Expressions.Expression.MemberInit(NewExpression newExpression, IEnumerable`1 bindings)
in Kendo.Mvc.Infrastructure.Implementation.Expressions.GroupDescriptorExpressionBuilder.CreateSelectBodyExpression()
in Kendo.Mvc.Infrastructure.Implementation.Expressions.GroupDescriptorExpressionBuilder.CreateSelectExpression()
in Kendo.Mvc.Infrastructure.Implementation.Expressions.GroupDescriptorExpressionBuilderBase.CreateQuery()
in Kendo.Mvc.Extensions.QueryableExtensions.Aggregate(IQueryable source, IEnumerable`1 aggregateFunctions)
in Kendo.Mvc.Extensions.QueryableExtensions.CreateDataSourceResult[TModel,TResult](IQueryable queryable, DataSourceRequest request, ModelStateDictionary modelState, Func`2 selector)
in Kendo.Mvc.Extensions.QueryableExtensions.ToDataSourceResult(IQueryable queryable, DataSourceRequest request, ModelStateDictionary modelState)
in Kendo.Mvc.Extensions.QueryableExtensions.ToDataSourceResult(IQueryable enumerable, DataSourceRequest request)
in Kendo.Mvc.UI.DataSource.Process(DataSourceRequest request, Boolean processData)
in Kendo.Mvc.UI.Grid`1.ProcessDataSource()
it seems that aggregates builder fails to get a property of class. But if I had an duplicate property name - I would find it at compilation time.
So, I have no idea what Kendo finds ambiguous.
Can you point out what I'm doing wrong? How to write an extension method which will satisfy my objectives correctly?