简体   繁体   中英

flex <mx:Array> bindable

I have a very simple doubt. I have declared an array using <mx:Array> ... </mx:Array> with objects in it. Now If I have to make it bindable the how can I do it?

Thanks in advance.

You probably do not want to use an Array in this case.

Even an array that is designated as "Bindable" will not throw an update event if any of its items are changed or added. This means that if you have an array specified as the dataprovider for some component (combobox, datagrid, etc.), then the component will not change if you update the source array.

You want to instead use an ArrayCollection, which you can think of as an "array with binding" in this case. You always want to use ArrayCollection over array when assigning a dataprovider.

Per the live docs:

Note: When defining a data binding expression that uses an array as the source of a data binding expression, the array should be of type ArrayCollection because the ArrayCollection class dispatches an event when the array or the array elements change to trigger data binding. For example, a call to ArrayCollection.addItem(), ArrayCollection.addItemAt(), ArrayCollection.removeItem(), and ArrayCollection.removeItemAt() all trigger data binding.

source: LiveDocs

So you would probably not want to bind to an array anyway. So assuming you make the change to array collection as recommended you will want to look at the tag, I'm not even sure if this tag is current or not but it used to handle what you are wanting to do. Personally if you're hard-coding your AC like this anyway it should be just as easy to do it in actionScript and easier to set the binding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM