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

[Solved] Row's header (rowindicator)

1 Answer 125 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.
Janne
Top achievements
Rank 1
Janne asked on 14 Jul 2009, 12:13 PM

Is there a way to set row's header color (or image) on RowEditEnded event?
I am in a need to visually show to user which rows have been modified since last
db update and row's header would be a nice place for that.

Regards
Janne

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 17 Jul 2009, 11:24 AM
Hi Janne,

The following code asumes that you are binding the grid to a collection of Person objects.
It will set background color of the RowIndicator  to Red for the edited rows.
Note that we keep the edited records in a 'dirtyData' collection. This allows persistence of  our formatting even on sorting , grouping and scrolling the grid.

public MainPage()  
        {  
            InitializeComponent();  
            this.RadGridView1.ItemsSource = Person.GetSampleObservableCollectionOfPersons();  
            this.RadGridView1.RowEditEnded += new EventHandler<Telerik.Windows.Controls.GridViewRowEditEndedEventArgs>(RadGridView1_RowEditEnded);  
            this.RadGridView1.RowLoaded += new EventHandler<RowLoadedEventArgs>(RadGridView1_RowLoaded);  
 
        }  
 
        void RadGridView1_RowLoaded(object sender, RowLoadedEventArgs e)  
        {  
            if (dirtyData.Contains(e.Row.DataContext as Person))  
            {  
                e.Row.ChildrenOfType<IndicatorPresenter>().First().Background = new SolidColorBrush(Colors.Red);  
            }  
        }  
 
        List<Person> dirtyData = new List<Person>();  
 
        void RadGridView1_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)  
        {  
            if (e.Row.DataContext as Person != null)  
                dirtyData.Add((Person) e.Row.DataContext);  
        } 

In case you have troubles adapting this to your projects , just let me know.

Kind regards,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Janne
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or