Flex Datagrid的动态ItemRenderer

时间:2011-12-15 09:59:09

标签: flex datagrid flex4 itemrenderer

我有带动态列的DataGrid。列将包含ItemRendrer。我不熟悉动态添加ItemRenderer 我的代码是:

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

WorkNatureRenderer是一个mxml组件。(Hbox包含TextInputButton

<?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>

但是当我添加它时,我得到了错误1067: Implicit coercion of a value of type Class to an unrelated type mx.core:IFactory.

任何示例或链接..

1 个答案:

答案 0 :(得分:1)

试试这个

myList.itemRenderer = new ClassFactory(WorkNatureRenderer);

我想这会帮助你...我不确定..