在特定 DataGrid 行中显示 itemRenderer...其他为空
我有一个通过数组填充的 DataGrid。 DataGrid 中的最后一列使用 ItemRenderer(按钮)。我想在某些行中显示按钮,但不在其他行中显示按钮(将其留空)。我到处寻找示例,甚至寻找如何执行此操作的线索(在 DG 上尝试过 labelFunction 等),但找不到任何相关信息。任何帮助将不胜感激。谢谢!
I have a DataGrid populated via an Array. The last column in the DataGrid uses an ItemRenderer (Button). I want to show the Button in certain rows but not in others (leave those empty). I've looked everywhere for an example or even a clue how to do this (tried labelFunction on DG, etc.) but can't find anything about it. Any help would be appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧......在(很多)帮助下,弄清楚了。
首先,我不确定为什么 itemRenderer 需要一个容器,但它确实需要。还必须从 itemRenderer 而不是从主应用程序检查数组...再次,我不知道为什么,因为调试器显示它正在经历完全相同的循环/事件等)。
如果有兴趣,这里是代码的相关部分:
主要应用程序:---
{col1:'',col2:'',col3:'',col4:'',col5:'',col6:'',col7:'',col8:'',col9:'',col10:'' , col11:'哟'}];
公共函数 initData():void
{ xferSchedule.dataProvider = schedArray; }
]]>
Okay... with (lots of) help, figured it out.
First off, I'm not sure why the itemRenderer requires a container but it does. The array must also be checked from the itemRenderer and not from the main application... again, I don't know why since the debugger shows it going through the exact same loop/events, etc.).
If interested here's the relevant parts of the code:
Main App:---
{col1:'', col2:'', col3:'', col4:'', col5:'', col6:'', col7: '', col8:'', col9:'', col10:'', col11:'yo'}];
public function initData():void
{ xferSchedule.dataProvider = schedArray; }
]]>
项目渲染器不必是容器,它必须实现 IDataRenderer(
Button
则不然)。人们可以扩展Button
并实现此接口以获得一个简单的按钮渲染器。如果您希望它有条件地显示,您将通过根据数据在渲染器中处理这些条件来实现此目的。an item renderer does not have to be a container, it has to implement
IDataRenderer
(aButton
does not). One could extendButton
and implement this interface to get a simple button renderer. If you want it to display conditionally, you will accomplish this by handling those conditions within the renderer based on the data.现在这可能会变得有点复杂。我建议您定义 XML 而不是对象数组。如果节点具有类型属性按钮,那么它将在值类型为按钮的单元格创建按钮。
如何在再次动态的网格内动态创建按钮?
这可能会导致整个组件都是动态的。
Now this might get slightly complex. I would recommend you to define you an XML instead of Array of Objects. If the node has the type property button, then it would create button at that cell whose value type is button.
How to create a button dynamically inside a grid which is yet again dynamic?
This might end into the whole component being dynamic.