0

我们在项目中使用 Flex 4。这是一项要求。我们有一个带有一些行和列的 AdvancedDataGrid 控件。有一个产品列。因为产品的数量比较多,所以我们希望它显示在一个 textArea 中。我们有一个产品列的渲染器。单击产品列后,此文本区域应在单击的列上方可见。

我在 ProductsRenderer.mxml 中尝试了以下代码。这里的 x 和 y 是任意的。当我单击该列时,我看不到任何文本区域。

    <fx:Declarations>   
        <parsley:Configure/>
</fx:Declarations>

    <fx:Script>
        protected function clickHandler(event:MouseEvent):void
        {
            var textArea:TextArea = new TextArea();
            textArea.height = 40;
            textArea.width  = 50;
            textArea.x = //get x for TextArea;
            textArea.y = //get y for TextArea;
            textArea.visible = true;
            textArea.setFocus();
            textArea.text = fProducts;
        }

    ]]>
    </fx:Script>

<s:VGroup id="Box"
              paddingBottom="0"
              paddingTop="5"
              horizontalAlign="left" height="100%">
        <s:Label id="productsData" top="0" left="0" right="0" bottom="0" width="100%" click="clickHandler(event)"/>
</s:VGroup>

这里应该怎么做才能让文本区域显示在网格上?谢谢

4

1 回答 1

0

您没有将 textArea 添加到任何父容器。执行以下操作:

protected function clickHandler(event:MouseEvent):void
        {
            var textArea:TextArea = new TextArea();
            textArea.height = 40;
            textArea.width  = 50;
            textArea.x = //get x for TextArea;
            textArea.y = //get y for TextArea;
            textArea.visible = true;
            FlexGlobals.topLevelApplication.addChild(textArea); //this could be something else, showing an example here.
            textArea.setFocus();
            textArea.text = fProducts;
        }
于 2012-11-16T22:40:11.690 回答