ValueMember/DisplayMember distinct filter in Grid

3 posts, 0 answers
  1. Arnaud Vallette
    Arnaud Vallette avatar
    4 posts
    Member since:
    Aug 2009

    Posted 22 Dec 2011 Link to this post


    I have the feeling that my request has been answered somewhere but I can't find it, so after hours crawling support forums and docs I decided to post my own request.
    I can't send my sources on public areas but I will try to explain it as clear as possible :

    The context is a Silverlight application using RIA Services . The application initialization consists of User authentication and then 'Master data' loading. All master data are stored in the application context (client side) as lists of entities (countries, lookups, objects statuses,...) so it allows me to query only codes instead of using .Include("NavigationProperty") for most used properties.

    I have a RadGridView that displays list of products. Each product has a property 'CountryCode' which is a number (ISO Country code) that defines the country where it is produced. The grid column template uses a converter to display the country name instead of the country code (all relevant countries are loaded in the application initialization). This column also uses a custom method to get distinct values for the country that returns all country names loaded in the application context.
    The issue is that the filter then sends a request to the RIA service with a condition like 'CountryCode = 'France'" which is incorrect.

    How can I set the filter to display the country name but to use the country code for Filtering (something like Display/Value member in lists) ?

    Thanks in advance for the answer,
  2. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 23 Dec 2011 Link to this post

    Hello Arnaud,

    As I understand you use a Converter for the column binding. The IValueConverters  are for UI purposes. They do not take part in our data engine when it comes to filtering, sorting and so on. Our data engine operates over the "raw" data, i.e. it does not pass it through the IValueConverter. The IValueConverter is only used to display the raw data to the end-user, i.e. in the grid cells or in the distinct values list.

    If you apply a converter for the columns, it will be applied to the filter distinct values as well. So the distinct values will be the same as shown in the GridViewDataColumn. I do not understand why do you need to get the distinct values that return all the country names. Am I missing something?

    All the best,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Arnaud Vallette
    Arnaud Vallette avatar
    4 posts
    Member since:
    Aug 2009

    Posted 23 Dec 2011 Link to this post

    Hi Didie,

    I was not actualy using a IValueConverter, but an Extension method of my class to display the country name instead of the country code. By reading your post, I understood that the IValueConverter could be the solution. I implemented it and changed the Load distinct value to return codes as well. Now all is working perfectly.

    It was just too simple !

    Thanks a lot
Back to Top