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

What event to use detecting a new row has been added

2 Answers 836 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 04 Nov 2010, 10:55 PM
What is the best event to detect when a new row has been added via binding?

For instance I have a WPF (form application) with a grid bound to a ObservableCollection<foo> class. When I add a new object to the collection, it is added to grid automatically.

I want to detect that a new row has been added by the grid and put the select a cell and put it in edit mode.

I'm currently accomplishing this task using the RowLoaded event and it is working. However, once there are enough rows added that cause the grid to have a vertical scroll bar AND the user then scrolls up in the grid then the RowLoaded event fires again ... even though the row already exists. So I've had to had special code to really identify in RowLoaded when the event fired from a true add to the collection.

I would like to know if there is another event to use and I've inspected several of them. I thought DataLoaded would work and it fires, however I cannot figure out a way to make a particular cell selected and placed in mode via this event. The code that I'm using that is working in RowLoaded event is this
if (e.DataElement != null)
{
    ((GridViewCell)e.Row.Cells[7]).BeginEdit();
}

Thanks ... Chad

2 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 05 Nov 2010, 04:00 PM
Hi Chad,

You can use either your observable collection CollectionChanged event or RadGridView.Items.CollectionChaged event. To handle the case when new row will not be visible you can use RadGridView.ScrollIntoViewAsync() method. I'm attaching a sample application that demonstrates this approach.

P.S. If you use Underlying observable collection CollectionChanged event you should call your custom code with a dispatcher since RadGridView should create proper container for this new item.

Regards,
Nedyalko Nikolov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ujwal
Top achievements
Rank 1
answered on 15 Jun 2017, 05:33 AM
works perfectly.. thanks!!
Tags
GridView
Asked by
Chad
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Ujwal
Top achievements
Rank 1
Share this question
or