DataGrid Column names don't seem to be binding
- by Jason
Sort of a Flex newbie here so bear with me. I've got a DataGrid defined as follows:
<mx:Script>
...
private function getColumns(names:ArrayCollection):Array {
var ret:Array = new Array();
for each (var name:String in names) {
var column:DataGridColumn = new DataGridColumn(name);
ret.push(column);
}
return ret;
}
</mx:Script>
<mx:DataGrid id="grid" width="100%" height="100%" paddingTop="0"
columns="{getColumns(_dataSetLoader.columnNames)}"
horizontalScrollPolicy="auto" labelFunction="labelFunction"
dataProvider="{_dataSetLoader.data}"
/>
...where _dataSetLoader is an instance of an object that looks like:
[Bindable]
public class DataSetLoader extends EventDispatcher {
...
private var _data:ArrayCollection = new ArrayCollection();
private var _columnNames:ArrayCollection = new ArrayCollection();
...
public function reset():void {
_status = NOTLOADED;
_data.removeAll();
_columnNames.removeAll();
}
...
When reset() is called on the dataSetLoader instance, the DataGrid empties the data in the cells, as expected, but leaves the column names, even though reset() calls _columnNames.removeAll(). Shouldn't the change in the collection trigger a change in the DataGrid?