简体   繁体   中英

How to set Header Text of AdvancedDatagrid Column with Multiple Color in FLEX?

I would like to set multiple colors of header text of a column in my advanced data grid. For Example: Suppose header text is: Price File Id *

where * is for representing mandatory. now I want "Price File Id" in black and "*" in red color. Following code showing full header text as Red.

column.headerText = "Price File Id *"
column.setStyle("headerStyleName","MyMandatoryDataGridStyleHeader");

Please help in this. I am not getting solution anywhere. Also not able to apply css differently.

You can use a HeaderRenderer for this column. In your advancedatagrid column code add following property

<mx:AdvancedDataGridColumn headerRenderer="{new ClassFactory(SampleHeaderRenderer)}"/>

And Create SampleHeaderRenderer.mxml with the following code

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:fx="http://ns.adobe.com/mxml/2009" 
                              xmlns:s="library://ns.adobe.com/flex/spark" 
                              xmlns:mx="library://ns.adobe.com/flex/mx" 
                              focusEnabled="true">
<s:Label text="Price File Id"/>
<s:Label text="*" styleName="MyMandatoryDataGridStyleHeader" />
</mx:HBox>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM