<mx:DataGrid dataProvider="{dp}">
<mx:columns>
<mx:DataGridColumn headerText="屬性" dataField="label" rendererIsEditor="true">
<mx:itemRenderer>
<fx:Component>
<mx:Label text="{data.label}"/>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="值" dataField="value" editorDataField="text">
<mx:itemEditor>
<fx:Component>
<mx:TextInput text="{data.value}"/>
</fx:Component>
</mx:itemEditor>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
數據源格式:[{label:"姓名", value:"張三"}, {label:"年齡", value:28}]。
通過 ItemRenderer 將單行數據渲染為「鍵值對」雙列,以最小代價實現垂直表頭效果,保持 DataGrid 排序、編輯、選中等原生能力。