Flex:更新数据网格 dataProvider 导致数据网格的可见属性设置为 TRUE

发布于 2024-10-15 08:21:35 字数 132 浏览 1 评论 0原文

我注意到 Flex 4 数据网格上的这种行为,我将网格的可见性设置为 FALSE。当我更新网格的 dataProvider 数据时,例如更新集合中实体的属性,网格将再次变为可见。

这是 Flex 中数据网格的默认行为吗?我如何禁用它?

I notice this behavior on the Flex 4's datagrid, where I set the gird's visible to FALSE. As I update the grid's dataProvider data, for example update an entity's property in the collection, the grid will become VISIBLE again.

is this the default behavior of a datagird in Flex? How do i disable it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兔姬 2024-10-22 08:21:35

我刚刚编写了一个快速示例:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
               creationComplete="application1_creationCompleteHandler(event)"
               >

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

            [Bindable]
            public var myData:ArrayCollection = new ArrayCollection;

            protected function application1_creationCompleteHandler(event:FlexEvent):void
            {
                var u:User;
                for (var i:int=0; i < 5; i++)
                {
                    u = new User();
                    u.name = "custom "+int(Math.random()*10);
                    u.phone = "0987 "+int(Math.random()*10);
                    myData.addItem(u);
                }

            }

            protected function button1_clickHandler(event:MouseEvent):void
            {
                myData.getItemAt(0).name = "test";
            }

        ]]>
    </fx:Script>
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
    <mx:DataGrid dataProvider="{myData}" visible="false">
        <mx:columns>
            <mx:DataGridColumn dataField="name" />
            <mx:DataGridColumn dataField="phone" />
        </mx:columns>
    </mx:DataGrid>
    <s:Button label="Change data" click="button1_clickHandler(event)" />    
</s:Application>

并且 DataGrid 可见性没有更改,因此您的代码中显然存在问题。
你能发布一些你的代码吗?

I've just coded a quick sample :

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
               creationComplete="application1_creationCompleteHandler(event)"
               >

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

            [Bindable]
            public var myData:ArrayCollection = new ArrayCollection;

            protected function application1_creationCompleteHandler(event:FlexEvent):void
            {
                var u:User;
                for (var i:int=0; i < 5; i++)
                {
                    u = new User();
                    u.name = "custom "+int(Math.random()*10);
                    u.phone = "0987 "+int(Math.random()*10);
                    myData.addItem(u);
                }

            }

            protected function button1_clickHandler(event:MouseEvent):void
            {
                myData.getItemAt(0).name = "test";
            }

        ]]>
    </fx:Script>
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
    <mx:DataGrid dataProvider="{myData}" visible="false">
        <mx:columns>
            <mx:DataGridColumn dataField="name" />
            <mx:DataGridColumn dataField="phone" />
        </mx:columns>
    </mx:DataGrid>
    <s:Button label="Change data" click="button1_clickHandler(event)" />    
</s:Application>

And the DataGrid visibility is not changed so there is obviously something wrong in your code.
Could you post some of your code?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文