2012-07-18 73 views
0

我们在项目中使用了Flex 4。这是一个要求。我们有一个包含一些行和列的AdvancedDataGrid控件。有一个产品列。由于产品数量较多,我们希望它在textArea中显示。我们有一个产品列的渲染器。一旦我点击产品栏,这个textarea应该在点击列的正上方可见。将文本区域添加到FLex中的Datagrid 4

我试过了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> 

这里应该做得到的网格中显示的文本区域?谢谢

回答

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; 
     }