开发者

Flex datagrid component problem

Guys I've a grid view in flex,

one of the columns is rendered like this:

<mx:DataGridColumn headerText="Cancel"  >
      <mx:itemRenderer>
       <fx:Component>
        <mx:Box width="100%" height="100%" horizontalAlign="center" verticalAlign="middle">
         <mx:Button label="Download" width="100%"  >
          <mx:click>someFunction();</mx:click>
         </mx:Button>
        </mx:Box>
       </fx:Component>
      </mx:itemRenderer>
      </mx:开发者_开发技巧DataGridColumn>

now I've a problem that the function in button click is not being recognized. It says "call to a possibly undefined function" even though it was defined. What is wrong with this? How do i make a button in a grid call a function in the same mxml file??

thanks


Your itemRenderer is considered its own encapsulated component so it's looking for someFunction() within the itemRenderer itself. To call a function you have defined in the mxml file that contains your DataGrid, try calling the function using outerDocument.someFunction();.

If you would like to define the function at the itemRenderer level, you could do something like this:

<mx:itemRenderer>
  <fx:Component>
    <mx:VBox>
      <fx:Script>
      <![CDATA[

        public function someFunction():void
        {
          // Do Something
        }

      ]]>
      </fx:Script>

      <mx:Button click="someFunction();"/>
    </mx:VBox>
  </fx:Component>
</mx:itemRenderer>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜