【问题标题】:How to access data of parent container from custom view in Flex?如何从 Flex 中的自定义视图访问父容器的数据?
【发布时间】:2012-09-30 00:12:57
【问题描述】:

我在 Flex 中有一个 TabNavigator 容器,在所有选项卡中我都有相同的视图(一堆按钮和一个网格)。

        <mx:TabNavigator id="myTabThing">
            <mx:VBox label="First tab"
                     width="100%"
                     height="100%">
                <view:myView/>
            </mx:VBox>
            <mx:VBox label="Second tab"
                     width="100%"
                     height="100%">
                <view:myView/>
            </mx:VBox>
        </mx:TabNavigator>

如何在 myView.mxml 中掌握选项卡导航器的数据? 我应该非常希望能够做一些事情,例如:

    <mx:Text text="{myTabThing.selectedChild}"/>

或者实际上基于所选子级的更复杂的东西(更改 myView 视图中列表的填充)。

Total Flex 新手在这里,如果我的问题很愚蠢,很抱歉。

【问题讨论】:

    标签: apache-flex components containers parent tabnavigator


    【解决方案1】:

    添加“this.parentDocument”会让你知道当前的标签。在这种情况下,试试

    <mx:Text text="{this.parentDocument.myTabThing.selectedChild}"/>
    

    如果要根据父级更改 MyView 中的列表,请检查“selectedChild”的 id。给 VBoxes 一个 id,然后像这样检查 id

    <mx:VBox id ="firstTab" label="First tab"
                 width="100%"
                 height="100%">
            <local:myView/>
    
    if(this.parentDocument.myTabThing.selectedChild.id == "firstTab"){...}
    

    【讨论】:

    • 谢谢!似乎正是我所需要的!当我真正尝试时,我会验证答案是否正确!但非常感谢!
    猜你喜欢
    • 2015-09-12
    • 2018-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-02
    • 1970-01-01
    • 2013-09-16
    相关资源
    最近更新 更多