2012-07-18 72 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; 
     }