通过多项选择找出 Spark 列表中取消选择的项目
在 Spark 列表中,我可以使用 change
事件来找出已选择或取消选择的项目。 分派的 IndexChangeEvent
对象具有保存此信息的属性 newIndex
和 oldIndex
。
但在允许多重选择的情况下,这不再起作用,因为 newIndex
和 oldIndex
可以引用仍然选定的元素的索引。
解决方案是将 selectedIndices
向量复制到另一个变量,并在选择更改后将此变量与 selectedIndices
进行比较,但这似乎有些复杂。
有谁知道是否有一种简单的方法可以获取用户取消选择而其他元素仍处于选中状态的索引/项目?
In a spark list I could use the change
event to find out which item has been selected or deselected.
The dispatched IndexChangeEvent
object has the properties newIndex
and oldIndex
holding this information.
But with multiple selection allowed this doesn't work anymore because newIndex
and oldIndex
could refer to indices of still selected elements.
A solution would be to copy the selectedIndices
vector to another variable and compare this variable with selectedIndices
after a change in selection, but this seems to be somewhat complex.
Does anyone know if there is an easy way two get the index/item a user is deselecting while other elements are still selected?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将需要存储选定的索引并比较差异。
You will need to store the selectedIndicies and compare the difference.
扩展自定义数据对象
_selected
,通过列表交互进行更新。它:
selectionChanged
。在
selected
设置器中 - 如果它确实发生了变化 - 您可以触发自己的冒泡selectionChanged
事件,并在需要的地方捕获它。SelectableItem.as - 表示列表的行数据的自定义数据结构
MyDataGrid.mxml
TestApplication.mxml
我希望这会有所帮助。
You could also extend your custom data object with
_selected
, which gets updated via the list interactions.it:
selectionChanged
.In the
selected
setter - if it actually changed - you can fire your own bubblingselectionChanged
event, and capture it wherever you need.SelectableItem.as - the custom data structure representing a row data of the list
MyDataGrid.mxml
TestApplication.mxml
I hope this helps.