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

[Solved] Merging column values but maintaining data type

1 Answer 115 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
FieldTRAKS
Top achievements
Rank 1
FieldTRAKS asked on 27 Nov 2009, 01:51 PM
I am binding my xml data to the datagrid  via the light weight datatable that you guys gave me. I have adjust each DataColumn class to have bool to indicate if the column should be visible in the grid. Most of the columns I hide are actually companion columns that have the unit associated with a value. For instance, there would be a Temperature column  and the next column would be Temperature unit Column. I would like merge the values of these columns but still be able to filter the value based on datatype. Is there an easy way to do this?

In the example above I want the Temperature column to show its value + value of its companion unit column but still be allowed to filter (such as Temperature > 30.)


1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 02 Dec 2009, 09:47 AM
Hello Matt ,

I have tried to illustrate a scenario close to yours ( please see the attached project) . There we have two fields - one with the value of a temperature and one with the unit.
Using a custom value converter we merge both values to have them displayed in a single column .
To preserve filtering we keep the DataMemberBinding pointing to the TempValue field.
To have the ValueConverter in action we replace the default cell template with a textblock bound to the underlying object via our converter.

To see all this in action just run the project attached. It uses a  List of .Net objects but with a small change in the Convert() method it can be easily adapted to use the  "datatable".

Regards,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
FieldTRAKS
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or