This is a migrated thread and some comments may be shown as answers.

[Solved] Problem while sorting in the Grid.

2 Answers 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sasikanth KS
Top achievements
Rank 1
Sasikanth KS asked on 22 Dec 2009, 02:42 PM
Hi,

While sorting an property at second level of the object then I am getting error "Invalid property or field", Please check the below code as well attached screenshot, in the below code "Fund Type" and "Ticker" is working as expected but "Fund Name" is getting error while sorting, "Fund Type" and "Ticker" is at first level but "Fund Name" is at second level. Is any thing I am missing, please suggest.

    investmentPerformance.Add(properties => properties.InvestmentInformation.InvestmentType)

                                        .Title(

"Fund Type");

 

    investmentPerformance.Add(properties => properties.InvestmentInformation.Investment.InvestmentLongName)

                                        .Title(

"Fund Name");

 

    investmentPerformance.Add(properties => properties.InvestmentInformation.Ticker)

                                        .Title(

"Ticker");

 


Thanks
--Sasi



2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 23 Dec 2009, 08:55 AM
Hello Sasikanth KS,

It seems you have discovered a bug in our code. Fortunately it is rather easy to fix. Please open the ExpressionExtensions.cs file (from the Telerik Extensions source) and replace the MemberWithoutInstance method implementation with this code:

public static string MemberWithoutInstance<T>(this Expression<Func<T, object>> expression) where T : class
        {
            MemberExpression memberExpression = expression.ToMemberExpression();

            if (memberExpression == null)
            {
                return null;
            }

            if (memberExpression.Expression.NodeType == ExpressionType.MemberAccess)
            {
                MemberExpression innerMemberExpression = (MemberExpression)memberExpression.Expression;
                
                while (innerMemberExpression.Expression.NodeType == ExpressionType.MemberAccess)
                {
                    innerMemberExpression = (MemberExpression)innerMemberExpression.Expression;
                }

                ParameterExpression parameterExpression = (ParameterExpression)innerMemberExpression.Expression;

                return memberExpression.ToString().Substring(parameterExpression.Name.ToString().Length + 1);
            }

            return memberExpression.Member.Name;
        }

Then rebuild the solution and use the produced assembly. We will release a hotfix build soon.

Regards,
Atanas Korchev
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.
0
Sasikanth KS
Top achievements
Rank 1
answered on 23 Dec 2009, 12:49 PM
Hi,

Thanks for the reply.

Thanks
--Sasi
Tags
Grid
Asked by
Sasikanth KS
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Sasikanth KS
Top achievements
Rank 1
Share this question
or