1 Reply Latest reply on Apr 12, 2010 2:22 AM by Sebastien V.

    DataGrid duplicate row selection problem




      I'm using a DataGrid in my AIR application with an array of names (string) as its data provider. The names of its items may not be unique. In the case where two rows have the same name im unable to select one of them.


      Clicking on it results in a correct DGrid.selectedIndex so my core  functionality isn't getting affected but the item doesn't get highlighted as it should. Instead its twin gets highlighted.


      This happens with the name appearing first on the list. The second occurence works fine.


      Only the highlighting is going wrong. Since the value in selectedIndex is correct its not too big of an issue but it looks defective when one of the rows jus doesnt seem to get selected.


      Please Help!!!



        • 1. Re: DataGrid duplicate row selection problem
          Sebastien V. Level 3

          That's because the selection is based on the == equality, so when you click on one of the two similar String, it will always select the first one.


          To avoid this, you should wrap your strings in different objects, so that they have different references, and the == equality will never be true for two similar but yet different elements.


          An easy way to do so is to use in your Array objects builded from the strings. For each String in your original array, add :

          { label:myString }

          to the grid dataProvider. Also do no forget to set the dataField property of your column to "label".