Flex 4.5 Spark DataGrid - 检测在选择更改处理程序中单击的列
我有一个带有 selectionMode="multipleRows"
的 Spark 数据网格。
我的数据网格中有三列。
我不希望当用户的点击落在行的第三列上时发生行选择。
仅当单击前两列之一时才应进行行选择。
我该如何实现这一目标?数据网格有一个 selectionChanging
事件,但处理程序中收到的 GridSelectionEvent
对象似乎没有提供有关发生单击的列的任何信息。
谢谢!
I have a spark datagrid with selectionMode="multipleRows"
.
I have three columns in the datagrid.
I don't want the row selection to happen when the user's click falls on the third column of a row.
The row selection should happen only when one of the first two columns is clicked.
How do I achieve this? There is a selectionChanging
event for the datagrid, but the GridSelectionEvent
object received in the handler does not seem to provide any information about the column on which the click happened.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道它已经 13 岁了,但今天我遇到了同样的问题,我是这样做的:
大黑客,但它正在工作
I know it's 13 years old, but I have same issue today, here how I done :
Big hack but it's working
我自己想出了这个办法。我不确定这是否是 Spark DataGrid 中的错误。下面的内容绝对是一个 hack 并且不干净。
在
DataGrid.as
文件的grid_mouseDownHandler
函数中,有一行:如果
DataGrid
的selectionMode
不是以下任何内容,则此行会导致columnIndex
设置为-1
GridSelectionMode.SINGLE_CELL
或GridSelectionMode.MULTIPLE_CELLS
。正如我在原来的问题中提到的,我需要我的数据网格的selectionMode
为GridSelectionMode.MULTIPLE_ROWS
。我对 DataGrid 进行了子类化并重新实现了 grid_mouseDownHandler (基本上是复制粘贴整个函数)。我仅更改了上面的行,以始终将
columnIndex
分配给event.columnIndex
。(我还必须将 grid_mouseDownHandler 引用的更多函数复制到我的子类,因为这些函数是 protected 或 mx_internal。(toggleSelection,extendSelection ,
isAnchorSet
)然后,在
selectionChanging
事件处理程序中,我可以执行以下操作:我意识到这不是一个干净的解决方案,但这是我能想到的最好的解决方案。也许有人可以提出更好的解决方案?
I figured this out myself. I am not sure if this is a bug in the spark DataGrid. The following is definitely a hack and not clean.
In the
grid_mouseDownHandler
function in theDataGrid.as
file, there is a line:This line is causing the
columnIndex
to be set as-1
if theselectionMode
of theDataGrid
is anything other thanGridSelectionMode.SINGLE_CELL
orGridSelectionMode.MULTIPLE_CELLS
. As I mentioned in the original question, I need my datagrid to have aselectionMode
ofGridSelectionMode.MULTIPLE_ROWS
.I sub-classed the DataGrid and re-implemented the
grid_mouseDownHandler
(basically copy-pasted the whole function). I changed only the above line to always assign thecolumnIndex
toevent.columnIndex
.(I also had to copy some more functions which were referenced by the
grid_mouseDownHandler
over to my sub-class because those functions were protected or mx_internal. (toggleSelection
,extendSelection
,isAnchorSet
)Then, in the
selectionChanging
event handler, I could just do the following:I realize that this is not a clean solution, but it is the best I could think of. Maybe someone can suggest a better solution?