Reputation: 25969
How do you bind the dataprovider of a DataGrid in Flex to an Array?
This doesn't seem to work:
<mx:DataGrid
id="valuesDataGrid"
editable="true"
width="100%"
height="100%"
dataProvider="{_metaDataKey.values}">
...
[Bindable]
public class EnumMetaDataKey{
private var _values:Array = [];
public function get values():Array { return _values; }
public function set values(value:Array):void { _values = value; }
...
Upvotes: 1
Views: 4197
Reputation: 111280
Use an ArrayCollection
instead. Array
s do not lend well to binding. IIRC, this is documented in the Flex 3 help on Binding to functions Objects and Arrays:
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 theArrayCollection
class dispatches an event when the array or the array elements change to trigger data binding. For example, a call toArrayCollection.addItem()
,ArrayCollection.addItemAt()
,ArrayCollection.removeItem()
, andArrayCollection.removeItemAt()
all trigger data binding.
Upvotes: 3