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

How do I display a different rep[resentation of a value in a filter

3 Answers 72 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry Newton
Top achievements
Rank 1
Terry Newton asked on 16 Nov 2011, 09:04 PM
I have  GridViewDataColumn with a constructed status field (using a CellTemplate) that I have set to sort using a numeric value (using a DataMemberBinding).  All fine and nice but I do not want to display that numeric value when the user filters the column.  I want to provide a value (using a converter perhaps) that the column filter UI will apply to render the numeric value for display in the selection list for the user to pick from so that use user will see a blank, 'Unapproved', 'Partial', or 'Approved',  instead of 0,1,2, or 3 as they get now. 

I have not yet found an example of how to control the representation within the filter control, but I assume there is a way (hopefully a simple one).
Can someone point me to where I can find how to do this? 

Thanks much.

3 Answers, 1 is accepted

Sort by
0
Terry Newton
Top achievements
Rank 1
answered on 28 Nov 2011, 07:45 PM
I am bumping this in hopes of getting a response.  I really do not want to bloat the dataset by adding the textual representation of the artificial status indicator to allow proper display of the textual representation in the filter list pulldown.  I would also lose the ability to sort it by default in an order other than alphabetically.
0
Rossen Hristov
Telerik team
answered on 29 Nov 2011, 10:11 AM
Hi Terry Newton,

I am afraid that the only way in which you can do that is by specifying an IValueConverter on the DataMemberBinding of the column. This IValueConverter will be used when generating the list of distinct values. However, in the lower part of the control the user will still have to type in 1,2,3 in order to filter since this process is one-way-only, i.e. 1->"one", but not the opposite. 

Of course the easiest way would be to add a new read-only property with the textual representation. Then you will not have to do anything.

Of course, you can always develop your very own custom filtering control if you do not like the stock one.

Regards,
Ross
the Telerik team

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

0
Terry Newton
Top achievements
Rank 1
answered on 29 Nov 2011, 04:16 PM
Thank you greatly for the response.  There was a gem in it.  The readonly property is a great idea, as I am already using a value converter to get the sort order I want.  I had not thought of that approach.  It avoids the need to serialize it as part of the dataset to the client, which was one of my biggest hangups.  I do not mind bloat on the client nearly as much as bloat in the comm layer.
Thanks.
Tags
GridView
Asked by
Terry Newton
Top achievements
Rank 1
Answers by
Terry Newton
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or