Sorry but that doesn't work, I have tried almost everything I could think of, including your advices, but can't succeed.
I put below a simple example of what I am trying to do.
 
There are 2 buttons supposed to change the cellRenderer onClick, you can see that the DataGrid is redrawn but the new cellRenderer isn't taken in account :(( I have tried with cellRenderer = 'boldRenderer' + cellRenderer = boldRenderer
 
Something I have discovered, in the mx:DataGrid tag, if you add  initialize="event.target.getColumnAt(1).cellRenderer =  boldRenderer" the cellRenderer is taken, but not if you use the creationComplete event.
 
I am out of ideas right now, starting to think it is not feasible :((
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Model id="testModel">
 <user>
  <name>Maegerman</name>
  <firstName>Philippe</firstName>
 </user>
 <user>
  <name>My name</name>
  <firstName>is nobody</firstName>
 </user>
</mx:Model>
<mx:DataGrid id="dg" dataProvider="{testModel.user}">
  <mx:columns>
  <mx:Array>
   <mx:DataGridColumn headerText="Name" columnName="name" />
   <mx:DataGridColumn headerText="First name" columnName="firstName"/>
  </mx:Array>
 </mx:columns>
</mx:DataGrid>
 
<mx:Button label="boldRenderer" click="dg.getColumnAt(1).cellRenderer =  'boldRenderer'; dg.dataProvider = dg.dataProvider; dg.redraw();"></mx:Button>
<mx:Button label="italicRenderer" click="dg.getColumnAt(1).cellRenderer =  'italicRenderer'; dg.dataProvider = dg.dataProvider; dg.redraw();"></mx:Button>
 
</mx:Application>
 
 
boldRenderer
----------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Label xmlns:mx="http://www.macromedia.com/2003/mxml" fontWeight="bold">
<mx:Script>
<![CDATA[
function setValue(str:String, item:Object, sel:Boolean){
 text = item.firstName;
}
]]>
</mx:Script>
</mx:Label>
 
italicRenderer
-----------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Label xmlns:mx="http://www.macromedia.com/2003/mxml" fontStyle="italic">
<mx:Script>
<![CDATA[
function setValue(str:String, item:Object, sel:Boolean){
 text = item.firstName;
}
]]>
</mx:Script>
</mx:Label>
 
 
Philippe Maegerman


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Manish Jethani
Sent: jeudi 8 septembre 2005 9:31
To: [email protected]
Subject: Re: [flexcoders] cellRenderer

On 9/7/05, Philippe Maegerman <[EMAIL PROTECTED]> wrote:

> If I would ask my question differently it would be :
> Is it possible to change cellRenderers on the fly, switching from
> cellRendererA to cellRendererB ?

I think changing the cell renderer that way should work - i.e it
should refresh the DataGrid with the new cells.  I haven't tried.  If
it doesn't work, you could try refreshing the grid by reassigning the
dataProvider

  grid.dataProvider = grid.dataProvider


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com



YAHOO! GROUPS LINKS




------------------------------------------------------------------
**STATEMENT OF CONFIDENTIALITY**

This e-mail and any attached files are confidential and intended solely for the use of the individual to whom it is addressed. If you have received this email in error please send it back to the person that sent it to you. Any views or opinions presented are solely those of author and do not necessarily represent those the Emakina Company. Unauthorized publication, use, dissemination, forwarding, printing or copying of this email and its associated attachments is strictly prohibited.

We also inform you that we have checked that this message does not contain any virus but we decline any responsability in case of any damage caused by an a non detected virus.
------------------------------------------------------------------

Attachment: boldRenderer.mxml
Description: boldRenderer.mxml

Attachment: dGridCellRenderer.mxml
Description: dGridCellRenderer.mxml

Attachment: italicRenderer.mxml
Description: italicRenderer.mxml

Reply via email to