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

[Solved] Sorting dynamic data

1 Answer 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David Rhodes
Top achievements
Rank 1
David Rhodes asked on 09 May 2013, 08:39 AM
Hi, i'm trying to get sorting working using dynamic data but it's throwing errors, when I try to sort I get the error

No property or field 'Forenames' exists in type 'Object'

[ParseException: No property or field 'Forenames' exists in type 'Object'] Telerik.Web.UI.ExpressionParser.ParseMemberAccess(Type type, Expression instance) +922 Telerik.Web.UI.ExpressionParser.ParseIdentifier() +382 Telerik.Web.UI.ExpressionParser.ParsePrimaryStart() +31 Telerik.Web.UI.ExpressionParser.ParsePrimary() +14 Telerik.Web.UI.ExpressionParser.ParseUnary() +262

Is it possible with dynamic data to sort?

protected void ResultsGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
.....................
 
    List<dynamic> contacts = new List<dynamic>();
    foreach (Entity result in results.Entities)
    {
        Contact contact = result.ToEntity<Contact>();
        contacts.Add(
            new
            {
                Id = contact.Id,
                Forenames = contact.FirstName,
                Surname = contact.FirstName,
                ReferenceNumber = contact.mps_ReferenceNumber,
                AddressLine1 = contact.Address1_Line1,
                AddressPostalCode = contact.Address1_PostalCode,
                AddressCountry = (contact.mps_address1_country == null) ? "" : contact.mps_address1_country.Name
            }
        );
    }
 
    ResultsGrid.DataSource = contacts;
}

1 Answer, 1 is accepted

Sort by
0
David Rhodes
Top achievements
Rank 1
answered on 09 May 2013, 08:43 AM
Found the answer!

<MasterTableView RetrieveDataTypeFromFirstItem="true">
Tags
Grid
Asked by
David Rhodes
Top achievements
Rank 1
Answers by
David Rhodes
Top achievements
Rank 1
Share this question
or