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

SelectedItem on Adding New Row

2 Answers 217 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Florian
Top achievements
Rank 1
Florian asked on 26 Feb 2012, 11:01 PM
Hello,

the behaviour of the SelectedItem propeties seems strange to me:

If inserting a new row in the grid, the SelectedItem is still the previous row. That's not what I expect, but it's ok, as far as the previous row is still mark in the grid.

After editing the first cell and clicking on the next cell, the SelectedItem changes to the new entry, but the grid still marks the previous row.

When the CellEditEnded event or RowEditEnded event is raised the SelectedItem differs from the property it is bound to! SelectedItem has been set back to previous item while the bound property is still the new item.

I tracked this behaviour with version 2011_2_0920. It is a bug or a missunterstanding on my side?

I also have two related questions:
1. Why has setting the CurrentItem no effect? The previous item is still marked on the grid.
2. Is there a possiblity to set the inserted item on top of the shown rows in the grid instead of the buttom?

Best greeetings
Florian Müller

2 Answers, 1 is accepted

Sort by
0
Florian
Top achievements
Rank 1
answered on 27 Feb 2012, 10:13 AM
I just read the correlating post How to set selected item to new row on insert button click event and repeat the question from Swathi:

How to get the insertion row at bottom so that i can set the isselected property for the new row?
0
Nedyalko Nikolov
Telerik team
answered on 29 Feb 2012, 11:39 AM
Hi,

Generally RadGridView supports two ways to insert new item - via Click here to insert new item UI and without this special new row. The special new row cannot be moved down its position is fixed (at the top of all rows). The described behavior is relevant for the case when new item UI is in use. The reason is that this new row may not be a part of the underlying collection so cannot be set as Selected and Current. If you do not use this new row you will be able to add items (if your collection implements INotifyCollectionChanged and IList interfaces). Unfortunately we cannot commit that this newly added row will be at the last or at the first position, since this item will be added to the grid according to current sorting, grouping and filtering.
Let me know if there is something unclear.

Greetings,
Nedyalko Nikolov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Florian
Top achievements
Rank 1
Answers by
Florian
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or