Or
if you do not want to create a new Renderer for only 1 property, you can simply configure the property as follows:
... <s:GridColumn width="100" dataField="myDataField" headerText="myHeaderText"> <s:headerRenderer> <fx:Component> <s:DefaultGridHeaderRenderer maxDisplayedLines="2" /> </fx:Component> </s:headerRenderer> </s:GridColumn> ...
if you look at the code inside the DefaultGridHeaderRenderer component, you will see that when you install it, it will change the value in the labelDisplay method
But, if you have many columns, and it can be boring to put the same code for a lot of time, just create a new component that extends the Datagrid spark (or nests depending on your need), then the code:
public function set columns(value:IList):void { for each (var gridColumn:GridColumn in value.toArray()) { var headerRenderer:ClassFactory = new ClassFactory(DefaultGridHeaderRenderer); headerRenderer.properties = {maxDisplayedLines: 2}; gridColumn.headerRenderer = headerRenderer; } _columns = value; } [Bindable] public function get columns():IList { return _columns; }
source share