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

RadGridView DataTrigger on Column to get Row object

2 Answers 156 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 27 Jun 2013, 01:55 PM
Hello,

I have a RadGridView.  It has as its source an ObservableCollection of a custom class.  There are three columns representing the data from this custom class.  What I am trying to do is apply a very specific converter to convert a value to a string.  I want to check the value in the first column and then apply the converter to the second and possibly the third column.
I tried using a DataTrigger.  If I set the target type to telerik:GridViewCell or telerik:GridViewRow, I am able to catch the row I want.  I think I should use the GridViewCell, but since all three columns refer to the same object, I am struggling to know which column the cell is in.  For my initial testing I am simply trying to change the background color of the cell I want, but later I will want to apply the Converter to the cell.

If I apply the converter directly to the column, I only get the value in the column and therefore do not know the corresponding value in the first column of the same row.

I am probably missing something to enable the functionality I want and am hoping someone could point me in the right direction.

Thanks,
Chris

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 02 Jul 2013, 08:15 AM
Hi Chris,

You could bind the column to the entire data item, not just to a specific property from it, i.e. DataMemberBinding={Binding}. Then you can return the value you would like to, from the converter. 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Chris
Top achievements
Rank 1
answered on 02 Jul 2013, 01:01 PM
Didie,
Thanks for the update.  Your way works better and is cleaner.
  I was in a hurry and needed it to work so I ended up creating a StyleSelector and applying a DataTemplate of a textbox to override the default behavior.
  With your suggestion I am able to use the ConverterParameter to pass in the name of the property that I was intending to display using the DataMemberBinding.  Then all the code is contained within the Converter.

Thanks,
Chris
Tags
GridView
Asked by
Chris
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Chris
Top achievements
Rank 1
Share this question
or