使用CellList禁用选择 [英] Disabling Selection with CellList

查看:116
本文介绍了使用CellList禁用选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 CellList

I have a CellList:

friendCellList = new CellList<PlayerDataEntity>(new PlayerCell());
friendCellList.setSelectionModel(new NoSelectionModel<PlayerDataEntity>());

我希望传递 NoSelectionModel 防止UI对用户选择单元列表中的项目作出反应。但是,用户可以正常选择元素。我不是正确应用选择模型吗?

I am hoping that passing the NoSelectionModel will prevent the UI from reacting to the user selecting items in the cell list. However, the user is able to select elements normally. Am I not applying the selection model correctly?

推荐答案

从NoSelectionModel的Javadoc:

From the Javadoc of NoSelectionModel:


选择模型不允许选择,但触发选择更改
事件。如果您想知道用户何时选择某个项目,但使用此模型,但
不希望视图根据所选内容进行更新。

A selection model that does not allow selection, but fires selection change events. Use this model if you want to know when a user selects an item, but do not want the view to update based on the selection.

这就是它的作用:在标准主题中,这将导致行不再以蓝色突出显示(cellListSelectedItem样式类)。但是,它仍然会以黄色突出显示(cellListKeyboardSelectedItem样式类)。此外,SelectionChangeEvent仍将被解雇。

That's what it does: In the Standard theme, this will result in the row not being highlighted in blue anymore ("cellListSelectedItem" style class). However, it will still be highlighted in yellow ("cellListKeyboardSelectedItem" style class). Also, the SelectionChangeEvent will still be fired.

要关闭SelectionChangeEvent,请使用

To turn off the SelectionChangeEvent, use

cellList.setSelectionModel(new NoSelectionModel<String>(), 
  DefaultSelectionEventManager.<PlayerDataEntity>createWhitelistManager());

无参数的白名单管理器意味着您无法选择任何列。

The whitelist manager without arguments means, that you can't select any column.

如果您还想关闭黄色突出显示,则应使用不同的CellList.Resources实例实例化CellList:

If you also want to turn off the "yellow" highlighting, you should instantiate CellList with a different CellList.Resources instance:

public interface MyResources extends CellList.Resources {
  @Override
  @Source("com/mypackage/my.css")
    Style cellListStyle();
}
...
friendCellList = new CellList<PlayerDataEntity>(new PlayerCell(),
    (MyResources) GWT.create(MyResources.class);

my.css:

my.css:

.cellListEvenItem {}
.cellListKeyboardSelectedItem {}
.cellListOddItem {}
.cellListSelectedItem {}
.cellListWidget {}

这篇关于使用CellList禁用选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆