michael_teter
04-10-2008, 02:46 AM
Howdy.
I'm very new to Flex (3), and I've got this DataGrid. I want to programmatically affect the contents of some of the columns based on their underlying data. I know this is possible, and I've seen some examples of how to do it. However, I haven't seen one quite like how I envision it (and hope to be able to do it).
Here's my expectation of how it should be possible. If it is possible this way, then I need guidance on syntax or declarations/arguments to get it right.
My pseudocode idea:
<mx:Script>
<![CDATA[
private function myRenderer(???) : ? {
if (currentCellData == "Dog") ?make the text presented in the cell be "D"?
else ?make the text presented in the cell be "-"?
}
]]>
</mx:Script>
...
<mx:DataGrid ...>
<mx:DataGridColumn ... itemRenderer="{myRenderer}"/>
That's about as simple as I can describe it. I've seen some interesting examples here and there, including http://weblogs.macromedia.com/pent/ , but so far I don't believe I've seen something exactly like I describe.
Lastly, in the body of the function myRenderer(), I will also later want to instead show an image instead of text. I assume I would be creating an image control of some sort and returning that to the cell.
Thanks very much.
Michael
I'm very new to Flex (3), and I've got this DataGrid. I want to programmatically affect the contents of some of the columns based on their underlying data. I know this is possible, and I've seen some examples of how to do it. However, I haven't seen one quite like how I envision it (and hope to be able to do it).
Here's my expectation of how it should be possible. If it is possible this way, then I need guidance on syntax or declarations/arguments to get it right.
My pseudocode idea:
<mx:Script>
<![CDATA[
private function myRenderer(???) : ? {
if (currentCellData == "Dog") ?make the text presented in the cell be "D"?
else ?make the text presented in the cell be "-"?
}
]]>
</mx:Script>
...
<mx:DataGrid ...>
<mx:DataGridColumn ... itemRenderer="{myRenderer}"/>
That's about as simple as I can describe it. I've seen some interesting examples here and there, including http://weblogs.macromedia.com/pent/ , but so far I don't believe I've seen something exactly like I describe.
Lastly, in the body of the function myRenderer(), I will also later want to instead show an image instead of text. I assume I would be creating an image control of some sort and returning that to the cell.
Thanks very much.
Michael