防止选择火花列表中的特定项目
我有一个 Spark 列表,其中有一个自定义 itemRenderer
用于渲染列表中的每个项目。 我希望阻止用户选择该列表中的项目(基于某些自定义逻辑)。
我实现这一目标的最佳方法是什么?
以下是我的列表的定义方式:
当然,我有一个项目渲染器定义为类 <代码>com.sample.MyItemRenderer。
I have a Spark List which has a custom itemRenderer
for rendering each item in the List.
I wish to prevent an item in that list from being selected (based on some custom logic) by the user.
What is the best way I can achieve this?
Here's how my List is defined:
<s:List id="myList" itemRenderer="com.sample.MyItemRenderer" />
and of course, I have a item renderer defined as the class com.sample.MyItemRenderer
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,项目的选择是由列表单独处理的,所以我想说你可以从那里进行管理。我会在列表中的对象上有一个名为“可选择”或类似的字段,当列表项发生更改时,检查新项目是否实际上可以选择,如果不是,那么您可以选择它清除选择或重置为之前的选择。您可以通过响应列表组件上的“更改”事件并在 IndexChangeEvent 上调用“preventDefault”来实现此目的,如下所示:
MyObject 类的相关部分如下:
The selection of items is handled by the list alone as far as I know, so I would say that you can manage it from there. I would have a field on the Objects that are in the list called "selectable" or something like that and when the list item is changing check to see if the new item is actually selectable and if it isn't then you can either have it clear the selection or reset to the previous selection. You can accomplish that by reacting to the "changing" event on the list component and calling "preventDefault" on the IndexChangeEvent as follows:
The relevant part of the MyObject class is as follows: