我自己想通了。我不确定这是否是Spark DataGrid中的错误。以下是绝对的黑客和不干净。
在DataGrid.as
文件grid_mouseDownHandler
功能,有一行:
const columnIndex:int = isCellSelection ? event.columnIndex : -1;
此行是造成columnIndex
被设置为-1
如果DataGrid
的selectionMode
比其他任何GridSelectionMode.SINGLE_CELL
或GridSelectionMode.MULTIPLE_CELLS
。正如我在原始问题中提到的,我需要我的数据网格有selectionMode
的GridSelectionMode.MULTIPLE_ROWS
。
我子类的DataGrid和重新实现了grid_mouseDownHandler
(基本上是复制粘贴的整体功能)。我只改变了上面的一行,总是把columnIndex
分配到event.columnIndex
。
(我也不得不复制其中一些是由grid_mouseDownHandler
在引用我的子类,因为这些功能得到保护或mx_internal更多的功能。(toggleSelection
,extendSelection
,isAnchorSet
)
然后,在selectionChanging
事件处理程序,我可以做到以下几点:
if(2 == event.selectionChange.columnIndex)
{
event.preventDefault();
}
我知道这是不是一个干净的解决方案,但它是我的Coul最好想到。也许有人可以提出更好的解决方案?