flex
Flex
Flex2でDataGridに動的カラム作成
<!-- hoge.mxml --> <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="initColumns()"> <mx:DataGrid id="grid" right="10" left="10" top="10" bottom="10" lockedColumnCount="1"></mx:DataGrid> <mx:Script source="hoge.as" /> </mx:Application>
// hoge.as private function initColumns() : void { var cols:Array = this.gridManHour.columns; cols.length = 0; // 既存カラムを削除 var col:DataGridColumn = new DataGridColumn(); col.headerText ="ほげ"; col.dataField = "hoge" cols.push(col) col = new DataGridColumn(); col.headerText ="ふが"; col.dataField = "fuga" cols.push(col) // 再代入しないとダメらしい this.gridManHour.columns = cols; // dataProviderは最後に定義する this.gridManHour.dataProvider = [{"hoge": "a", "fuga": "b"},{"hoge": "c", "fuga": "d"}]; };
flex.txt · 最終更新: 2007/10/03 07:51 by 127.0.0.1