Error when binding to Aggregate SumFunction

13 posts, 0 answers
  1. tungnt185
    tungnt185 avatar
    40 posts
    Member since:
    Aug 2009

    Posted 02 Dec 2009 Link to this post

    Hello Telerik team,
    I've error when I'm using Aggregate function in Column Grid.
     
    <telerikGridView:GridViewDataColumn HeaderTextAlignment="Center" TextAlignment="Right" DataMemberBinding="{Binding EmployeeDeduction}"
                            <telerikGridView:GridViewDataColumn.AggregateFunctions> 
                                <telerikData:SumFunction FunctionName="EmployeeDeduction" SourceField="EmployeeDeduction" ResultFormatString="{}{0:c}" /> 
                            </telerikGridView:GridViewDataColumn.AggregateFunctions> 
    </telerikGridView:GridViewDataColumn> 

    The error message like below in stack trace. When I use Count Function everything work fine but when I use Sum,Min,Max function error occurs. My EmployeeDeduction has data type is Money in SQL server 2008. I think it's a bug of Aggregate Sum function in Q3.

    Message: Unhandled Error in Silverlight Application 
    Code: 4004     
    Category: ManagedRuntimeError        
    Message: System.ArgumentException: Invalid property or field - 'EmployeeDeduction' for type: Entity 
       at Telerik.Windows.Data.Expressions.MemberAccessTokenExtensions.CreateMemberAccessExpression(IMemberAccessToken token, Expression instance) 
       at Telerik.Windows.Data.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName) 
       at Telerik.Windows.Data.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName, Boolean liftMemberAccessToNull) 
       at Telerik.Windows.Data.Expressions.PropertyAccessExpressionBuilder.CreateMemberAccessExpression() 
       at Telerik.Windows.Data.Expressions.EnumerableSelectorAggregateFunctionExpressionBuilder.CreateMemberSelectorExpression() 
       at Telerik.Windows.Data.Expressions.EnumerableSelectorAggregateFunctionExpressionBuilder.CreateAggregateExpression() 
       at Telerik.Windows.Data.EnumerableSelectorAggregateFunction.CreateAggregateExpression(Expression enumerableExpression) 
       at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.<ProjectionPropertyValueExpressions>b__3(AggregateFunction f) 
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() 
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) 
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) 
       at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateProjectionInitExpression() 
       at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateAggregateFunctionsProjectionMemberBinding() 
       at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.<CreateMemberBindings>d__0.MoveNext() 
       at System.Linq.Buffer`1..ctor(IEnumerable`1 source) 
       at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) 
       at System.Linq.Expressions.ReadOnlyCollectionExtensions.ToReadOnlyCollection[T](IEnumerable`1 sequence) 
       at System.Linq.Expressions.Expression.MemberInit(NewExpression newExpression, IEnumerable`1 bindings) 
       at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateSelectBodyExpression() 
       at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateSelectExpression() 
       at Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilderBase.CreateQuery() 
       at Telerik.Windows.Data.QueryableExtensions.Aggregate(IQueryable source, IEnumerable`1 aggregateFunctions) 
       at Telerik.Windows.Controls.GridView.GridViewDataControl.CreateAggregateResults() 
       at Telerik.Windows.Controls.GridView.GridViewDataControl.CalculateAggregates() 
       at Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass37.<Bind>b__36() 
       at Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action) 
       at Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(Object newValue) 
       at Telerik.Windows.Controls.GridView.GridViewDataControl.OnApplyTemplate() 
       at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)      
     
    Line: 57 
    Char: 13 
    Code: 0 

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 02 Dec 2009 Link to this post

    Hi,

    This exception is related to not finding property in the resolved item type - can you sort, group or filter by this field in your case? Please post also more info about how the grid is bound.

    Best wishes,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. tungnt185
    tungnt185 avatar
    40 posts
    Member since:
    Aug 2009

    Posted 02 Dec 2009 Link to this post

    Hello,
    Everything worked fine when I comment out AggregateFunction portion.
    I'm using WCF RIA service PDC to for Model then I'm used a ViewModel to bind to DataContext in the View.
    After I used DomainDataSource.Data in ViewModel for binding to RadGridView's ItemsSource.
    Beside I also bind SelectedItem and CurrentItem of this RadGridView to DomainDataSource.DataView.CurrentItem with Mode = TwoWay.
    I don't know if this help you find out my problems ?
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 03 Dec 2009 Link to this post

    Hi,

    It will be better if you can send us small example (via support ticket) where we can reproduce and debug the grid behavior in your scenario.

    Sincerely yours,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. tungnt185
    tungnt185 avatar
    40 posts
    Member since:
    Aug 2009

    Posted 07 Dec 2009 Link to this post

    Hello again,

    I've send you an support ticket with an example.
    Please test it and give me a solution.

    Thanks you very much.
  7. Saumil Shah
    Saumil Shah avatar
    7 posts
    Member since:
    Oct 2009

    Posted 23 Feb 2010 Link to this post

    I am getting the same error. Please let me know if anyone of you found the solution.
  8. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 23 Feb 2010 Link to this post

    Hi,

    Please post more info about your scenario and grid version.

    Sincerely yours,
    Vlad
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  9. Saumil Shah
    Saumil Shah avatar
    7 posts
    Member since:
    Oct 2009

    Posted 23 Feb 2010 Link to this post

    I am following "Telerik RadChart for Silverlight - Integration - Grouping and Aggregation" example. Only difference is I am using dynamic data from database intead of fixed data in the example. I can see data correctly in teleric gridview but when i try to bind same data in chart ( RadChart1.ItemsSource = RadGridView1.ItemsSource;), it is giving me following runtime exception.

    "An unhandled exception ('Unhandled Error in Silverlight Application
    Code: 4004
    Category: ManagedRuntimeError
    Message: System.ArguementException: Invalid property or field - 'propertyName' for type: AggregateFunctionGroup.

    Please let me know if you have any idea about the solution.
  10. Saumil Shah
    Saumil Shah avatar
    7 posts
    Member since:
    Oct 2009

    Posted 23 Feb 2010 Link to this post

    Here is the solution.

    If you are using grid paging then get your resultset in saparate variable. and instead of doing
    RadChart1.ItemsSource = RadGridView1.ItemsSource
    do following.
    RadChart1.ItemsSource = _localVariable;

    It has resolved my issue. I hope this will help.

    Thanks.
  11. Kirill Prokopenko
    Kirill Prokopenko avatar
    11 posts
    Member since:
    Sep 2009

    Posted 06 Apr 2010 Link to this post

    Hi,

    I had the same issue.  I had telerik grid bound to a collection of INotifyPropertyChanged objects. Collection was of type IEnumerable<INotifyPropertyChanged> but contained custom objects that implemented INotifyPropertyChanged interface and had extra properties. One of those properties was selected to get Summary aggregate function result. It failed exactly the same way described on the start of this thread.

    To fix it, I had to bind data grid explicitly to IEnumerable<MyTypeThatContainsProperty>. After that everything works fine. Since I had a lot of possible types bound to grid, I created ValueConverter that converts my generic IEnumerable<INotifyPropertyChanged> into specific IEnumerable<> of any type required but, of course, this approach adds some restrictions.

    I think the root cause is the fact (MAY BE) that when databinding is performed the property is taken from the GenericArgument collection of the items source's type instead of the object stored in the collection itself. Probably for better performance.

    Hope this information will help others.
  12. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 21 Jun 2010 Link to this post

    Hello,
    I have the same problem. When I try to use an aggregate function that needs to access to a field...

    The binding for the grid is
    ItemsSource="{Binding ElementName=beneficiaryDomainDataSource, Path=Data}"

    The datasourc is
    <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance domain:Beneficiary, CreateList=true}" Height="0" LoadedData="beneficiaryDomainDataSource_LoadedData" Name="beneficiaryDomainDataSource" QueryName="GetBeneficiariesQuery" Width="0" SubmittedChanges="beneficiaryDomainDataSource_SubmittedChanges">
                <riaControls:DomainDataSource.DomainContext>
                    <domain:SoContext />
                </riaControls:DomainDataSource.DomainContext>
            </riaControls:DomainDataSource>

    When I remove the datasource and use this in the page constructor to load my data it is working:
                LoadOperation<Beneficiary> op = this._context.Load(this._context.GetBeneficiariesQuery());
                grdBeneficiaire.ItemsSource = op.Entities;

    But this is not an acceptable solution for me as it is less practical to use and also it is much slower...

    Any work around?

    I find this feature does not work as advertised or I did not understand how to use it...

    If someone sent a sample to support, what was the answer?

    Thanks...



  13. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 22 Jun 2010 Link to this post

    Hello John,

    Recently we have fixed an issue when column aggregates were used and RadGridView was bound to DomainDataSource. Can you please download our latest internal build and verify the behavior on your side?

    Kind regards,
    Stefan Dobrev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  14. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 22 Jun 2010 Link to this post

    Hello Stefan,
    I linked my project to the lastest build dlls (controls, data and gridview in my case) and I confirm that this solves the problem.

    The aggregate functions work as expected. Even on calculated fields...

    Thanks,
    John.
Back to Top
DevCraft banner