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

Updating visual of a row

2 Answers 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Siew Fai Hoy
Top achievements
Rank 1
Siew Fai Hoy asked on 23 Sep 2009, 07:57 AM
On grid row loaded event, the background, foreground colours and many other visual properties of rows are updated according to some data conditions, for reporting flexibility the field names are also returned as part of data, so it is not possible to know what the field names are before hand.  This part is working fine and the formatting is also done correctly. 

However, when we want to make changes to the data that the grid is bound to, we would like the grid to also respond and change visual properties according to the same data conditions that we did during the Grid row loaded event. 
We have had some success in CellTemplates but this only works at the cell level, we would really like to change some visual properties of the entire row.

Q1:
Is there a way to identify a GridViewRowItem from code if we know the Record that has been changed?  (This is so we can format the row in code)

Q2:
Would there be any other solutions to achieve what I have outlined above?







2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 24 Sep 2009, 02:18 PM
Hi Siew Fai Hoy,

The best approach here is as follows:

Your business object ( the underlying object to the row) should implement the INotifyPropertyChanged interface.
This will allow the RadGridView to automatically update the UI , when a property changes. This way any property visualized in the row , or bound to the business object should update automatically.
This will eliminate the need to search for a specific row visual and update it explicitly.

In case y have troubles implementing this, just let me know some more details on your specific scenario and I can prepare a few lines of code for you.

All the best,
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.
0
Siew Fai Hoy
Top achievements
Rank 1
answered on 29 Sep 2009, 06:42 AM
Thanks, I received help on this from telerik support and the solution is similar to the way you've outlined.
For the benefit of others having the same query, this is how it got resolved.
The visual properties, e.g. Font Weight and Foreground are declared as notifiable properties in a viewmodel wrapping each datarow.  These are bound to each grid row when they are loaded.
The ViewModel also subscribes to the changes of the datarow properties.  On property changes, the visual properties are set according to data condition, this causes the grid row visual properties to change accordingly.

With Regards.
Tags
GridView
Asked by
Siew Fai Hoy
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Siew Fai Hoy
Top achievements
Rank 1
Share this question
or