开发者

Edit ArrayCollection through Item Renderer

开发者 https://www.devze.com 2023-03-13 04:46 出处:网络
I use a spark List with a custom item renderer and an ArrayCollection for dataProvider. The ItemRenderer looks something like

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 textb开发者_Python百科ox, 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?


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:

<mx:TextInput id="txtValue1" text="@{data.myFirstValue}"/>
<mx:TextInput id="txtValue2" text="@{data.mySecondValue}"/>

Now, any changes made to the TextInput will get pushed down to the data object as well.

Read more about Two way data binding.

0

精彩评论

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