Setting styles for all DataGrid components in a document

The DataGrid class inherits from the List class, which inherits from the ScrollSelectList class. The default class-level style properties are defined on the ScrollSelectList class, which the Menu component and all List-based components extend. You can set new default style values on this class directly, and these new settings are reflected in all affected components.

_global.styles.ScrollSelectList.setStyle("backgroundColor", 0xFF00AA);

To set a style property on the DataGrid components only, you can create a new instance of CSSStyleDeclaration and store it in _global.styles.DataGrid.

import mx.styles.CSSStyleDeclaration;
if (_global.styles.DataGrid == undefined) {
    _global.styles.DataGrid = new CSSStyleDeclaration();
}
_global.styles.DataGrid.setStyle("backgroundColor", 0xFF00AA);

When you create a new class-level style declaration, you lose all default values provided by the ScrollSelectList declaration, including backgroundColor, which is required for supporting mouse events. To create a class-level style declaration and preserve defaults, use a for..in loop to copy the old settings to the new declaration.

var source = _global.styles.ScrollSelectList;
var target = _global.styles.DataGrid;
for (var style in source) {
    target.setStyle(style, source.getStyle(style));
}

For more information about class-level styles, see Setting styles for a component class in Using ActionScript 2.0 Components.