Filtering Grid On Entity Associations

3 posts, 1 answers
  1. Richard Weeks
    Richard Weeks avatar
    95 posts
    Member since:
    Oct 2009

    Posted 30 Nov 2011 Link to this post

    If I have a RadGrid set up declaratively using an EntityDataSource, how can I set up filtering to cater for entity associations?

    For example, in the EntityDataSource, this will not work if I try to filter on "Model":

    Select="it.[Id], it.[ModelId], it.[Model].[Name] AS Model"

    This results in an error:

    Error: Sys.WebForms.PageRequestManagerServerErrorException: LIKE arguments must be of string type. Near member access expression, line 8, column 4.

    The auto-generated column (by selecting Refresh Schema in the design view of the EntityDataSource control) is as follows:
    <telerik:GridBoundColumn
        DataField="Model"
        DataType="System.String"
        FilterControlAltText="Filter Model column"
        HeaderText="Model"
        ReadOnly="True"
        SortExpression="Model"
        UniqueName="Model">
    </telerik:GridBoundColumn>

    Richard
  2. Answer
    Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 05 Dec 2011 Link to this post

    Hi Richard,

    Unfortunately such a scenario is not supported by the RadGrid control - what you need to do is to flatten your custom object into another one that will have only single object properties.

    Regards,
    Radoslav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Richard Weeks
    Richard Weeks avatar
    95 posts
    Member since:
    Oct 2009

    Posted 05 Dec 2011 Link to this post

    Luckily, I only needed a read-only representation of the data, so I was able to construct and query a view.

    This worked very well indeed.

    Richard
Back to Top