Setting properties on the ClassFactory for each itemRenderer is cool,
but does anybody know if there is a way to set style properties for
the item renderer?

thanks,
mark

--- In [email protected], "Thind, Aman" <[EMAIL PROTECTED]> wrote:
>
> Thank you so much Flexing. I wasn't aware I could pass parameters to an
> itemrenderer like that. Read a lot of documentations on renderers but
> never stumbled against that.
>  
> And Thank you so much Harald. That method of finding the column name
> inside the renderer itself is very cool. I just pasted your code in my
> application and poof. Thanks again for taking out the time.
>  
> Cheers,
> Aman
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Harald Dehn
> Sent: Thursday, May 24, 2007 3:47 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 could although access the column information in the following way
> inside your ItemRenderer
> 
>       var dg:DataGrid = (listData) ? DataGrid(listData.owner) : null;
> 
>       var column:DataGridColumn = (dg) ?
> dg.columns[listData.columnIndex] as DataGridColumn : null;
> 
> Harald
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Flexing...
> Sent: Donnerstag, 24. Mai 2007 08:03
> To: [email protected]
> Subject: Re: [flexcoders] One Item Renderer Component for Multiple
> Columns in a DataGrid - How to find name of column being rendered?
> 
> As mentioned in my previous email, you can pass the column name as
> property to the ItemRenderer
> 
> i.e.
> 
> 1. Create a public var columnName in your ItemRenderer
> 
> 2. Pass the column name as property to the ItemRenderer while creating
> it.
> 
> Here's the code you need to write
> 
>       var colRendererFactory:ClassFactory = new ClassFactory
> (com.lehman.smd.util.ValueRenderer);;
> 
>       colRendererFactory.properties = {columnName:"mycol2"};
> 
>       column.itemRenderer = colRendererFactory;
> 
> http://flex-apollo.blogspot.com/2007/05/single-itemrenderer-for-multiple
> .html
> <http://flex-apollo.blogspot.com/2007/05/single-itemrenderer-for-multipl
> e.html> 
> 
> On May 24, 2007, at 11:22 AM, Thind, Aman wrote:
> 
> 
> 
> 
> 
> 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 = newClassFactory(columnRenderer);
> 
> colRendererFactory.properties = {columnName:"mycol1"};
> 
> column1.itemRenderer = colRendererFactory
> 
> var colRendererFactory2:ClassFactory = newClassFactory(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.
> 
>  
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
> 
> 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.
>


Reply via email to