dataGridColumn.itemRenderer = new ClassFactory(customItemRanderer); In your case:
custColumn1.itemRenderer = new ClassFactory(ComputedStylesRenderer); --- In flexcoders@yahoogroups.com, "sbeausol" <sbeausol...@...> wrote: > > Hi- > > I've been able to implement a custom Text Color Item Renderer for a > datagrid based off of this post Custom item renderer > <http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.h\ > tml> . I've added 2 classes, a ComputedStylesColumn and > ComputedStylesRenderer and I can successfully implement this in the mxml > file, but I was hoping to build my datagrids dynamically with > actionscript. > > the mxml that works: > <mx:DataGrid id="dg1" initialize="dg1.dataProvider = dp" paddingTop="0" > paddingBottom="0" verticalAlign="middle" > > <mx:columns> > <mx:DataGridColumn headerText="Name" dataField="name" width="140"/> > <mx:DataGridColumn headerText="Symbol" dataField="symbol" width="60" /> > <local:ComputedStylesColumn headerText="Price" dataField="price" > stylesFunction="computeStyles" > itemRenderer="ComputedStylesRenderer" /> > </mx:columns> > </mx:DataGrid> > > I've been able to reconstruct most things in actionscript except for the > itemRenderer="ComputedStylesRenderer". > > when I try this: > var custColumn1:ComputedStylesColumn = new ComputedStylesColumn(); > custColumn1.dataField = "price"; > custColumn1.headerText = "Price"; > custColumn1.width = 75; > custColumn1.stylesFunction = computeStyles; > > Everything works except: > > custColumn1.itemRenderer = ComputedStylesRenderer(); > "Implicit coercion of a value of type ComputedStylesRenderer to an > unrelated type mx.core:IFactory" >