AdvancedDataGridでセルの内容をコピーする方法は各所で紹介されているが
階層データやセル選択モード(MULTIPLE_CELLS)に対応しているものがない。
いろいろ試行錯誤した結果、AdvancedDataGridを継承して、下記のようなコードを書けば
選択中のセルの情報を取得できそうなことがわかった。
最初はlistItemsを使おうと思ったのだけれど、listItemsは基本的に表示中のアイテムしか
保持していないため、選択中のデータの取得には使えなかった。
それにしても、この程度のことが簡単にできないFlexにちょっと萎えた。

public var selectedCellDatas:Array = [];
override protected function addCellSelectionData(uid:String, columnIndex:int, selectionData:AdvancedDataGridBaseSelectionData):void {
	var column:AdvancedDataGridColumn = columns[selectionData.columnIndex] as AdvancedDataGridColumn;
	var label:String = column.itemToLabel(selectionData.data);
	selectedCellDatas.push({
		rowIndex: selectionData.rowIndex,
		columnIndex: selectionData.columnIndex,
		label: label
	});
	super.addCellSelectionData(uid, columnIndex, selectionData);
}
override protected function clearCellSelectionData():void {
	selectedCellDatas = [];
	super.clearCellSelectionData();
}

Leave a Reply

(required)

(required)


4 + = seven

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>