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

Select Item After Insert

3 Answers 99 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 11 May 2010, 05:24 PM
I have a grid view sorted by a date column, users can add records to the grid view via the "Click here to add new item" row, a context menu, or ribbon button.  All the non-grid view method just call the BeginInsert method of the grid view which seems to work without issue.  I would like to automatically set the inserted row as the selected row of the grid view when the insert is complete.  To do this I am using edit complete handler bellow:

     private void crashRowEditComplete(object sender, GridViewRowEditEndedEventArgs e) 
        { 
            if (e.EditAction == GridViewEditAction.Commit 
                && e.EditOperationType == GridViewEditOperationType.Insert) 
            {                 
                ApplicationState.Carrier.Crashes.Add((Crash)e.NewData); 
                ApplicationState.Carrier.Drivers.Add(((Crash)e.NewData).Driver); 
                ApplicationState.Carrier.Vehicles.Add(((Crash)e.NewData).Vehicle); 
                crashListGrid.SelectedItem = e.NewData; 
            } 
        } 

The handler is running fine (checked through debug and the fact that the data does get written out to the file - dependent on the three Add statements), but the item is not getting selected correctly.  Instead the first row in the grid always gets selected.  This seemed like a pretty simple requirement and I have manipulated the grid selection previously without issue.

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 12 May 2010, 09:00 AM
Hello Andrew,

How do you commit the changes when you finish editing? Do you click on the Enter button or click on another row of the gridview? If you click the Enter button - the currently added row is selected by default (with no additional code). If you click on another row though - it would be the selected one.

Here is a short video that demonstrates it.

Regards,
Veskoni
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
Andrew
Top achievements
Rank 1
answered on 12 May 2010, 01:33 PM
I am submitting a support ticket which contains a project that demonstrates this not being the case in the WPF rad grid.
0
Veselin Vasilev
Telerik team
answered on 17 May 2010, 08:44 AM
Hello Andrew,

While we are investigating the problem, I am posting a link to a workaround here(link).



Greetings,
Veskoni
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.
Tags
GridView
Asked by
Andrew
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or