Each item in the dataprovider must be unique. If you have references to the
same object at two different indexes things will not work as expected.
The thing is that they ARE 2 different objects. Each selectedIndex represents different objects.
For instance, the top row = patientList.selectedItem.PatientId: 191
and the duplicate row below = patientList.selectedItem.PatientId: 192
Can you make a small test case?
The strange thing is that we have datadrids all over this app that are formatted exactly the same way and this behavior never happens:
Here's another example:
<mx:DataGridColumn headerText="Name" dataField="FirstName" />
<mx:DataGridColumn headerText="Relationship" dataField="RelationshipToPatientTypeId"/>
I don't see anything obvious from the snippets. I would need a full test
case in about 20 lines that I can just copy and paste.
I would be careful of your change handler. Maybe onItemSelected somehow
resets selectedItem or selectedIndex.
So the problem has been solved and sorry for the long reply the culprit was the sort function:
Previously it was this:
dataProvider.sort.fields = [new SortField("LastName",true, false), new SortField("FirstName",true, false)];
and all I had to do was to make it more distinct by adding the PatientId field to the mix.
dataProvider.sort.fields = [new SortField("LastName",true, false), new SortField("FirstName",true, false), new SortField("PatientId",true, false)];
Thanks for everyone's reply!