DataGrid Column names don't seem to be binding

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2010-03-23T21:45:38Z Indexed on 2010/03/23 22:43 UTC
Read the original article Hit count: 308

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about flex

Related posts about datagrid