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

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

问题描述

创建一个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 。这是混淆闪光/柔性的原因是,数据网格用平等来确定当它找到了一个匹配的行。这可能是固定的修补框架使用全等(===),但更好的答案现在是做作为该职位建议,敷你的价值观中的对象,以便有没有对这个问题的风险。你也可以看到,如果你增加了一些相同的对象,因为这个例子在链接显示相同的行为。这里是一个工作的例子,以确保你有你需要的。

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天全站免登陆