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

ValueMember/DisplayMember distinct filter in Grid

2 Answers 102 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Arnaud Vallette
Top achievements
Rank 1
Iron
Arnaud Vallette asked on 22 Dec 2011, 09:49 PM
Hello,

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,
Arnaud

2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 23 Dec 2011, 01:01 PM
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,
Didie
the Telerik team

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

0
Arnaud Vallette
Top achievements
Rank 1
Iron
answered on 23 Dec 2011, 02:11 PM
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
Arnaud
Tags
GridView
Asked by
Arnaud Vallette
Top achievements
Rank 1
Iron
Answers by
Dimitrina
Telerik team
Arnaud Vallette
Top achievements
Rank 1
Iron
Share this question
or