MattFS218
11-10-2008, 10:56 AM
I'm using an editable DataGrid to display a list of keys and values. My dataGrid looks like
<mx:DataGrid editable="true" showHeaders="false" alternatingItemColors="[#F2F2F2, #F2F2F2]" borderStyle="none" themeColor="#F7F7F7" resizableColumns="false" horizontalGridLines="false" verticalGridLines="false" borderColor="#F2F2F2" width="100%">
<mx:dataProvider>
<mx:Object key="" value="Matthew what happens when this field is longer than the space providee"/>
<mx:Object key="" value="Web Person"/>
<mx:Object key="" value="Co and Co."/>
<mx:Object key="" value="matt@coco.com"/>
<mx:Object key="Current VPN:" value="SonicWall"/>
<mx:Object key="Timeframe:" value="ASAP"/>
<mx:Object key="VMware:" value="no"/>
</mx:dataProvider>
<mx:columns>
<mx:DataGridColumn headerText="Key" editable="false" textAlign="right" fontSize="10" dataField="key"/>
<mx:DataGridColumn headerText="Value" fontSize="16" dataField="value"/>
</mx:columns>
</mx:DataGrid>
I would like for the width of the key column of the DataGrid to be fully viewable but as small as
possible. In order to do this, I need some way of calculating the the pixel width of the longest key
at a certain fontSize (the key value's load at runtime, from my server, so I cannot fix the pixel
width in mxml).
What's the best way to accomplish this? DataGridColumns only accept pixels in their width
attribute.
Thanks.
<mx:DataGrid editable="true" showHeaders="false" alternatingItemColors="[#F2F2F2, #F2F2F2]" borderStyle="none" themeColor="#F7F7F7" resizableColumns="false" horizontalGridLines="false" verticalGridLines="false" borderColor="#F2F2F2" width="100%">
<mx:dataProvider>
<mx:Object key="" value="Matthew what happens when this field is longer than the space providee"/>
<mx:Object key="" value="Web Person"/>
<mx:Object key="" value="Co and Co."/>
<mx:Object key="" value="matt@coco.com"/>
<mx:Object key="Current VPN:" value="SonicWall"/>
<mx:Object key="Timeframe:" value="ASAP"/>
<mx:Object key="VMware:" value="no"/>
</mx:dataProvider>
<mx:columns>
<mx:DataGridColumn headerText="Key" editable="false" textAlign="right" fontSize="10" dataField="key"/>
<mx:DataGridColumn headerText="Value" fontSize="16" dataField="value"/>
</mx:columns>
</mx:DataGrid>
I would like for the width of the key column of the DataGrid to be fully viewable but as small as
possible. In order to do this, I need some way of calculating the the pixel width of the longest key
at a certain fontSize (the key value's load at runtime, from my server, so I cannot fix the pixel
width in mxml).
What's the best way to accomplish this? DataGridColumns only accept pixels in their width
attribute.
Thanks.