Hi Flexing,
Thanks for the reply!
Yes I already set my itemrenderers in actionscript using:
column.itemRenderer = new ClassFactory
(com.lehman.smd.util.ValueRenderer);
for all my columns.
My problem is inside the itemRenderer component, I do not know the name
of the column that invoked it, so do not know which column value to pick
and render
Eg this is my renderer:
------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Text xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " text="{formatValue(data)}"
color="{signColor}">
<mx:Script>
<![CDATA[
import mx.formatters.NumberFormatter;
[Bindable]
public var signColor:int;
public function formatValue(data:Object):String
{
var value:Number = Number(data.<Do Not Know Which Column Name To Use
As Many Columns Render Using This > );
if(value < 0)
{
signColor = 0xff0000;
}
else
{
signColor = 0x000000;
}
return numFormat.format(value);
}
]]>
</mx:Script>
<mx:NumberFormatter id="numFormat" rounding="nearest"
useThousandsSeparator="true"/>
</mx:Text>
--------------------------
where data =
<resultdetail>
<col1>
"1234.5"
</col1>
<col2>
"-5342"
</col2>
</resultdetail>
Many Thanks,
Aman
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Flexing...
Sent: Thursday, May 24, 2007 2:24 PM
To: [email protected]
Subject: Re: [flexcoders] One Item Renderer Component for Multiple
Columns in a DataGrid - How to find name of column being rendered?
You need to use Action-Script to set the column renders:
var colRendererFactory:ClassFactory = new ClassFactory(columnRenderer);
colRendererFactory.properties = {columnName:"mycol1"};
column1.itemRenderer = colRendererFactory
var colRendererFactory2:ClassFactory = new ClassFactory(columnRenderer);
colRendererFactory2.properties = {columnName:"mycol2"};
column2.itemRenderer = colRendererFactory2;
Hope this helps.
On May 24, 2007, at 10:40 AM, Thind, Aman wrote:
Hello,
I have many columns in my DataGrid that have similar values and
I need to render them in a similar manner.
So I wish to write just one itemRenderer component and set that
as the renderer of all these columns.
So I believe each column will invoke my renderer when my grid
shows up.
However, the default data that is passed to the itemRenderer is
just the XML notation of one single row that is currently being
renderered in the grid.
I do not have any information regarding which column actually
invoked my renderer so do not know which value to use.
Eg all my columns have the same component registered as their
itemRenderer and this is what I get in the "data" variable:
<resultdetail>
<col1>
"1234.5"
</col1>
<col2>
"-5342"
</col2>
</resultdetail>
Now in my renderer I want to format the number but I do not know
which column invoked it and so which value to pick.
Is there anything passed to the renderer that tells the header
of the column which is being currently rendered by the custom
itemrenderer?
I do not want to write renderer_col1, renderer_col2 etc as the
columns and their dataprovider are dynamic.
Many Thanks,
Aman
LB | Tokyo
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - This message is intended only for the personal
and confidential use of the designated recipient(s) named above. If you
are not the intended recipient of this message you are hereby notified
that any review, dissemination, distribution or copying of this message
is strictly prohibited. This communication is for information purposes
only and should not be regarded as an offer to sell or as a solicitation
of an offer to buy any financial product, an official confirmation of
any transaction, or as an official statement of Lehman Brothers. Email
transmission cannot be guaranteed to be secure or error-free. Therefore,
we do not represent that this information is complete or accurate and it
should not be relied upon as such. All information is subject to change
without notice.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
This message is intended only for the personal and confidential use of the
designated recipient(s) named above. If you are not the intended recipient of
this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited. This
communication is for information purposes only and should not be regarded as an
offer to sell or as a solicitation of an offer to buy any financial product, an
official confirmation of any transaction, or as an official statement of Lehman
Brothers. Email transmission cannot be guaranteed to be secure or error-free.
Therefore, we do not represent that this information is complete or accurate
and it should not be relied upon as such. All information is subject to change
without notice.