I am having a repeatable problem with both Flex 2 and 3 when
using a sorted DataGrid.
When doing the following sequence an error occurs:
1) Fill a DataGrid with object data
2) User sorts the grid using header click
3) User or system adds a new object to the grid and in the
same process system sets the DataGrid's selectedItem property to
the newly added
4) An error is produced when referencing the selectedItem
When investigating this issue, it appears that the
selectedItem property is set to
null, although the selectedIndex value does have a number.
The grid "looks" fine (i.e. it has the row highlighted
correctly)... but there is nothing in selectedItem.
This only seems to happen when adding, immediately selecting
(with code) a new object when the grid is currently sorted. Also, a
user generated event (i.e. click)
WILL select the row just fine.
As of now, the only way around this problem seems to be to
remove the sort before adding and selecting the item, and then
putting it back in (a real pain in the neck in a large
Please see the attached code for an example of this.