View Full Version : align DataGrid header differently than data

08-27-2006, 05:48 AM
I am new to Flex and am trying to set the alignment on the header of a DataGrid to "center" and right-align the data in some of the columns but cannot get this to work. Any help is greatly appreciated. Here is what I have:

<?xml version="1.0"?>
<!-- DataGrid control example. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:XMLList id="employees">
<name>Christina Coenraets</name>
<email>[email protected]</email>
<name>Joanne Wall</name>
<email>[email protected]</email>
<mx:Panel title="DataGrid Control Example" height="100%" width="100%"
paddingTop="10" paddingLeft="10" paddingRight="10">

<mx:Label width="100%" color="blue"
text="Select a row in the DataGrid control."/>

<mx:DataGrid id="dg" width="100%" height="100%" rowCount="5" headerStyleName="headerStyle" dataProvider="{employees}">
<mx:DataGridColumn dataField="name" headerText="Name"/>
<mx:DataGridColumn dataField="phone" headerText="Phone"/>
<mx:DataGridColumn dataField="email" headerText="Email"/>
<mx:DataGridColumn dataField="salary" headerText="Salary" textAlign="right"/>

10-06-2006, 07:51 PM
Just add the text-align property for each column and set the value right. or just add another style DataGrid{text-align: right;} for all the columns

03-14-2008, 07:29 AM
cachanchan: the solution you suggested does not work. I am not quite sure if there is any solution to it.

03-14-2008, 07:47 AM
OOps !! no there is a simple solution...