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

Using DistinctValuesLoading event

1 Answer 97 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nikhil Pant
Top achievements
Rank 1
Nikhil Pant asked on 03 Feb 2010, 10:00 PM
My intention is to use the 'DisplayValueHolder.DisplayValue' for the filter list user interface and 'DisplayHolder.ID' for creating a query which will return the filtered data.

        public class DisplayValueHolder
        {
             public string ID{get;set;}
             public string Value{get;set;}
        }

Is it possible to use the GridView's 'DistinctValuesLoading' event to return a collection of objects like DisplayValueHolder  which contains different values for display and the data?

Nikhil

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 04 Feb 2010, 09:04 AM
Hello Nikhil Pant,

If the column is bound to a property of type DisplayValueHolder, then yes, you can interfere and return your own collection of DisplayValueHolder's in the DistinctValuesLoading event handler. You might want to add an IValueConverter to the column's DataMemberBinding in case you want to show the DisplayValue instead of the whole DisplayValueHolder. This will also display the DisplayValue instead of the whole business object in the column's cells. Or you can override the ToString method of DisplayValueHolder to return its DisplaValue. There are a number of options here.

Another option would be to create your own custom filtering control and configure it in any way that you need. When you have your own custom filtering control you have absolute power over what is going on, i.e. what distinct values are shown, etc. Here is a tutorial on how to create one.

I hope this helps.

All the best,
Ross
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
GridView
Asked by
Nikhil Pant
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or