is there a way to control the text positioning in the datagrid cells in Flex so that all text in subsequent columns align on the same rows?
A:
Try an itemRenderer like this
<mx:HBox width="100%" height="100%" vertical-align="middle">
<mx:Label text="{data.text}"/>
</mx:HBox>
Your text will line up on the same baseline assuming it's all the same point size. Note that all columns will have to use the same itemRenderer, or one like it. I use that pattern a lot even for images, progress bars, etc.
Robusto
2010-03-20 12:50:26
That should work, but I dislike adding containers just for layout reasons. That's why Flex 4 separates Containers and Layouts into two things. Using containers for the pure reason of Layout makes the Flex app run slower.
Luis B
2010-03-22 20:27:37
A:
Use one of these Label styles. These should work for most things:
textAlign="left|right|center"
textDecoration="none|underline"
textIndent="0"
Here is an example of its use an DataGridColumn's itemRenderer:
<mx:DataGrid>
<mx:columns>
<mx:DataGridColumn>
<mx:itemRenderer>
<mx:Component>
<mx:Label width="100%" height="100%" textAlign="center"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGridColumn>
Let me know if that helped! :)
Luis B
2010-03-22 20:34:11