Flex DataGrid/DataProvider bug?

你离开我真会死。 提交于 2019-12-11 07:05:52

问题


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:


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>


来源:https://stackoverflow.com/questions/4259250/flex-datagrid-dataprovider-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!