I created a component that is multiple datagrids side by side that share the same columns (each datagrid is the same as the one before but with different data).
Problem
The header text only shows up on the last datagrid. How can I get the text to show up on all the datagrid headers?
Here is how I instantiate the component.
<common:PageDataGrid width="100%" height="100%"
numGroups="5" numRows="9" dataProvider="{createData(5, 9)}">
<common:columns>
<mx:DataGridColumn dataField="ext" headerText="EXT." width="45"/>
开发者_Go百科 <mx:DataGridColumn dataField="name" headerText="ASSIGNED TO"/>
</common:columns>
</common:PageDataGrid>
Here is how I am creating the datagrids
for(var i:uint=0; i < _numGroups; i++)
{
dataGrid = new DataGrid();
dataGrid.headerHeight = 25;
dataGrid.rowCount = _numRows;
dataGrid.rowHeight = 25;
dataGrid.percentWidth = 100;
dataGrid.dataProvider = dataGridProviders.getItemAt(i);
dataGrid.columns = this._columns;
dataGrid.addEventListener(DataGridEvent.HEADER_RELEASE, onHeaderRelease);
this.addChild(dataGrid);
}
Needed to do a deep copy of the datagridcolumns before I assigned them to the datagird. Here is what I needed to do.
for(var i:uint=0; i < _numGroups; i++)
{
dataGrid = new DataGrid();
dataGrid.headerHeight = 25;
dataGrid.rowCount = _numRows;
dataGrid.rowHeight = 25;
dataGrid.percentWidth = 100;
dataGrid.dataProvider = dataGridProviders.getItemAt(i);
// Deep Copy
registerClassAlias("mx.controls.dataGridClasses.DataGridColumn", DataGridColumn);
var columnsCopy:Array = new Array(this._columns.length);
for(var j:uint=0; j < this._columns.length; j++)
{
columnsCopy[j] = ObjectUtil.copy(this._columns[j]) as DataGridColumn;
}
// End Deep Copy
dataGrid.columns = columnsCopy;
dataGrid.addEventListener(DataGridEvent.HEADER_RELEASE, onHeaderRelease);
this.addChild(dataGrid);
}
精彩评论