通过项目渲染器编辑ArrayCollection
我使用带有自定义项目渲染器的 Spark List
和用于 dataProvider
的 ArrayCollection
。
ItemRenderer 看起来像
<mx:TextInput id="txtValue1" text="{data.myFirstValue}"/>
<mx:TextInput id="txtValue2" text="{data.mySecondValue}"/>
但是,即使我更改了 txtValue1 或 txtValue2 中的文本,这些文本实际上并没有在 ArrayCollection 内的对象中更改。
myFirstValue
和 mySecondValue
使用 [Bindable]
标记进行修饰。
我的理解是,如果将 text
属性设置为绑定某个属性,则应自动应用更改。
因此,我使用的 HACK (或者我认为)是监听每个文本框的 focusOut
事件,并访问父数据提供程序并手动设置值。
我做错了什么?它应该像这样工作吗?
还是我理解错了什么?
I use a spark List
with a custom item renderer and an ArrayCollection
for dataProvider
.
The ItemRenderer looks something like
<mx:TextInput id="txtValue1" text="{data.myFirstValue}"/>
<mx:TextInput id="txtValue2" text="{data.mySecondValue}"/>
However, even though I change the text in txtValue1
or txtValue2
, those are not actually changed in the object inside the ArrayCollection.
myFirstValue
and mySecondValue
are decorated with the [Bindable]
tag.
My understanding is that if the text
property is set to be bound a certain property, the changes should be automatically applied.
So the HACK (or so I think) that I use is to listen to the focusOut
event of each textbox, and access the parent data provider and set the the values manually.
What am I doing wrong? Is it supposed to work like this?
Or what did I understand wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,flex 中的绑定是单向的。换句话说,
data
对象中的更改会在 UI 中更新,但反之则不然。您需要使用2路绑定。从 Flex 4.0 开始,这变得非常容易。请注意“@”符号的使用:
现在,对
TextInput
所做的任何更改也将被推送到data
对象。详细了解双向数据绑定。
By default, binding in flex is one-way. In other words, changes in your
data
object are updated in the UI but not the other way around.You need to use 2-way binding. This is very easy since Flex 4.0. Notice the use of the "@" sign:
Now, any changes made to the
TextInput
will get pushed down to thedata
object as well.Read more about Two way data binding.