Flex DataGrid/DataProvider 错误? [英] Flex DataGrid/DataProvider bug?

查看:25
本文介绍了Flex DataGrid/DataProvider 错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建数据网格和数据提供者,如果数据提供者包含 2 个相同的值 ({"A","A","B"}),当您将鼠标悬停在任何包含A"的行上时,所有包含的行"A" 也会突出显示.

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?

推荐答案

Whydna 你分享的帖子是正确的http://jonathanbranam.net/solutions/datagrid-highlights-wrong-row.这让 flash/flex 感到困惑的原因是数据网格使用相等性来确定它何时找到了一行的匹配项.这可以通过修补框架以使用严格相等 (===) 来解决,但现在更好的答案是按照该帖子的建议进行并将您的值包装在一个对象中,以便不存在此问题的风险.如果您添加了几个相同的对象,您也会看到相同的行为,如链接中的示例所示.这是一个有效的示例,可确保您拥有所需的内容.

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>

这篇关于Flex DataGrid/DataProvider 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆