Dynamic ItemRenderer for Flex Datagrid

2019-08-06 13:54发布

I have DataGrid with Dynamic Columns. The columns will contain ItemRendrer. I'm not familiar with dynamically adding ItemRenderer.
My code is:

var column:DataGridColumn = new DataGridColumn();
column.headerText = item;
column.width=150;
column.dataField=item;
column.itemRenderer = WorkNatureRenderer ;
cols.push(column);

WorkNatureRenderer is a mxml component.(Hbox containing TextInput and Button)

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">

    <s:TextInput/>
    <s:Button/>

</mx:HBox>

But when I add this I got an Error 1067: Implicit coercion of a value of type Class to an unrelated type mx.core:IFactory.

Any examples Or Links..

1条回答
ら.Afraid
2楼-- · 2019-08-06 14:37

Try this

myList.itemRenderer = new ClassFactory(WorkNatureRenderer);

i guess this will help u...IM NOT SURE..

查看更多
登录 后发表回答