Flex datagrid组件问题
伙计们,我在 Flex 中有一个网格视图,
其中一列呈现如下:
<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>
现在我遇到一个问题,按钮单击中的功能无法被识别。它说“调用可能未定义的函数”,即使它已定义。这有什么问题吗?如何使网格中的按钮调用同一 mxml 文件中的函数?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
itemRenderer
被视为其自己的封装组件,因此它会在itemRenderer
本身内查找someFunction()
。要调用您在包含DataGrid
的 mxml 文件中定义的函数,请尝试使用outerDocument.someFunction();
调用该函数。如果您想在 itemRenderer 级别定义该函数,您可以执行以下操作:
Your
itemRenderer
is considered its own encapsulated component so it's looking forsomeFunction()
within theitemRenderer
itself. To call a function you have defined in the mxml file that contains yourDataGrid
, try calling the function usingouterDocument.someFunction();
.If you would like to define the function at the itemRenderer level, you could do something like this: