给你个例子
<?xml version="1.0"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script><![CDATA[
import mx.collections.ArrayCollection
import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn
private var fields:Array = ['id', 'name']
private var ac:ArrayCollection = new ArrayCollection([
{id: 1, name: 'aaaa'},
{id: 2, name: 'bbbb'},
{id: 3, name: 'cccc'}
])
private function button1_clickHandler(e:MouseEvent):void {
var columns:Array = []
for each (var field:String in fields) {
var column:AdvancedDataGridColumn = new AdvancedDataGridColumn()
column.dataField = column.headerText = field
if(field == 'name') {
column.itemRenderer = new ClassFactory(TextInputRenderer)
}
columns.push(column)
}
adg.dataProvider = ac
adg.columns = columns
}
]]></fx:Script>
<fx:Declarations>
<fx:Component id="myComponent" className="TextInputRenderer">
<mx:TextInput text="@{data.name}"/>
</fx:Component>
</fx:Declarations>
<mx:AdvancedDataGrid id="adg" width="400" height="300">
</mx:AdvancedDataGrid>
<s:controlBarContent>
<s:Button label="create columns" click="button1_clickHandler(event)"/>
</s:controlBarContent>
</s:Application>
默认情况下,C1FlexGrid仅有一行多表头,如何来动态的给它添加多表头? 1.添加行和列:通过FlexGrid.Columns.Add和FlexGrid.Rows.Add方法添加行和列。 2.添加多行表头:通过FlexGrid.ColumnHeaders.Rows.Add方法,在ColumnHeaders区域添加多行的欢迎分享,转载请注明来源:内存溢出
评论列表(0条)