Updating visual of a row

3 posts, 0 answers
  1. Siew Fai Hoy
    Siew Fai Hoy avatar
    12 posts
    Member since:
    Sep 2009

    Posted 23 Sep 2009 Link to this post

    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. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 24 Sep 2009 Link to this post

    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.
  3. DevCraft banner
  4. Siew Fai Hoy
    Siew Fai Hoy avatar
    12 posts
    Member since:
    Sep 2009

    Posted 29 Sep 2009 Link to this post

    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.
Back to Top