1
votes

Creating a datagrid and dataprovider, if the dataprovider contains 2 of the same value ({"A","A","B"}), when you hover over any of the rows containing "A" all rows containing "A" will also get highlighted.

Anyone else notice this issue?

1
I've never seen anything like that. What's your code look like? - wajiw
Just a simple data grid object binded to a ArrayCollection. Then add duplicate strings to the ArrayCollection. - Andy Hin
I'm having that exact problem. Except, I am not inserting the same instance of the object. I am doing: dataProvider.AddItem("A"); dataProvider.AddItem("A"); - Andy Hin
I'm not sure it makes sense to use a dataprovider that consists only of strings. Normally your DataGrid contains one or more columns where each of those columns dataField references a property from the objects within your dataprovider. Could you please post an example that shows what you are doing? - Gerhard Schlager

1 Answers

2
votes

Whydna you are on the right track with the post you shared http://jonathanbranam.net/solutions/datagrid-highlights-wrong-row. The reason this is confusing flash/flex is that the datagrid uses equality to determine when it has found a match for a row. This could be fixed by patching the framework to use strict equality (===) but the better answer for now is to do as that post suggests and wrap your values in an object so that there is not risk of this issue. You will also see the same behavior if you added several identical objects, as the example at the link shows. Here is a working example to make sure you have what you need.

<mx:DataGrid id="dataGrid" dataProvider="{gridData}" creationComplete="init()">
    <mx:columns>
        <mx:DataGridColumn dataField="title" headerText="Title" />
    </mx:columns>
</mx:DataGrid>

<mx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;

        [Bindable] private var gridData:ArrayCollection;    

        protected function init():void
        {
            gridData = new ArrayCollection();

            for(var i:uint = 0; i < 10; i++)
            {
                gridData.addItem({title: "This is an item"});   
            }

        }

    ]]>
</mx:Script>