flex 3 迭代对象值
我有一个代表数据库表的对象。 我想迭代这个对象并打印每个值。 我可以用什么来做到这一点?
我想在我的 mxml 中执行此操作,而不是
为每个对象属性执行此操作,我想创建一个输入字段
i have an object which represents a database table. I want to iterate through this object and print printing each value. What can i use to do this?
i want to do this inside my mxml not actionscript
for each object attribute i want to create an imput field
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查找有关 Flex 3 循环的文档。 如果你这样做,你会发现:
而不是尝试创建输入每个对象的字段,我建议您查看 DataGrid和自定义 ItemEditors。
Look up the documentation on Flex 3 looping. If you do, you'll find this:
Instead of trying to create an input field for each object, I'd suggest you take a look at DataGrid and custom ItemEditors.
我同意这个答案没有用。 它仅适用于通用对象,不适用于用户声明的对象
对象。
然而,这里有一些代码应该/可以使用上面建议的describeType来工作。 (而且我真的不认为它太复杂)。 请注意,仅公开公共属性/方法等:
I agree that this answer isn't useful. It only works with generic objects, not user declared
objects.
However, here's some code that should/could work using the describeType as suggested above. (And I don't really think it's too complex). Be aware that only public properties/methods, etc. are exposed:
“for...in”的问题在于它仅迭代动态属性。 也就是说,如果您的对象被定义为类(并且不是动态的),则“for..in”不会给出任何内容。
ActionScript 文档建议使用describeType() 来获取固定属性,但对于这个简单的任务来说它看起来过于复杂......
The problem with "for...in" is that it iterates only on dynamic properties. That is, if your object is defined as a Class (and not dynamically), "for..in" won't give anything.
The ActionScript documentation suggest to use describeType() for fixed properties, but it looks over-complicated for this simple task…
您可以像 actionscript 一样编写它,但将其包含在带有 script 标记的 mxml 文件中:
You can write it like actionscript but include it inside the mxml file with the script tag: