Ledneh
06-07-2006, 06:13 PM
I've been trying to work out methods for using HTML formatting in DataGrid cells. So far, here's what I've come up with from the help docs and Google and what not:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:DataGrid id="storyGrid" width="400" height="300" variableRowHeight="true" left="20" top="20">
<mx:dataProvider>
<mx:ArrayCollection>
<mx:source>
<mx:Object Price="11.99">
<mx:Artist>
<![CDATA[<b>Pave<i>ment</i></b>]]>
</mx:Artist>
<mx:Album>
<b>Slanted and Enchanted</b>
</mx:Album>
</mx:Object>
<mx:Object Artist="Pavement" Album="Brighten the Corners" Price="11.99" />
</mx:source>
</mx:ArrayCollection>
</mx:dataProvider>
<mx:columns>
<mx:Array>
<mx:DataGridColumn dataField="Artist">
<mx:itemRenderer>
<mx:Component>
<mx:Text x="0" y="0" width="100%" htmlText="{data.Artist}"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="Album" />
<mx:DataGridColumn dataField="Price" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Application>
Now, all this works just fine for the DataGridColumn for which the HTML renderer is defined. But the rest just blast out the tags without rendering them.
To fix that, I COULD copy and paste the item renderer for each column, changing the data property as I go, but that feels repetitious and wasteful. So I wanted to ask, is there any way to specify to the DataGrid, "render all HTML contents in your tags" or, failing that, a way to specify a default itemRenderer for the whole grid that renders HTML?
Thanks!
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:DataGrid id="storyGrid" width="400" height="300" variableRowHeight="true" left="20" top="20">
<mx:dataProvider>
<mx:ArrayCollection>
<mx:source>
<mx:Object Price="11.99">
<mx:Artist>
<![CDATA[<b>Pave<i>ment</i></b>]]>
</mx:Artist>
<mx:Album>
<b>Slanted and Enchanted</b>
</mx:Album>
</mx:Object>
<mx:Object Artist="Pavement" Album="Brighten the Corners" Price="11.99" />
</mx:source>
</mx:ArrayCollection>
</mx:dataProvider>
<mx:columns>
<mx:Array>
<mx:DataGridColumn dataField="Artist">
<mx:itemRenderer>
<mx:Component>
<mx:Text x="0" y="0" width="100%" htmlText="{data.Artist}"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="Album" />
<mx:DataGridColumn dataField="Price" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Application>
Now, all this works just fine for the DataGridColumn for which the HTML renderer is defined. But the rest just blast out the tags without rendering them.
To fix that, I COULD copy and paste the item renderer for each column, changing the data property as I go, but that feels repetitious and wasteful. So I wanted to ask, is there any way to specify to the DataGrid, "render all HTML contents in your tags" or, failing that, a way to specify a default itemRenderer for the whole grid that renders HTML?
Thanks!