我有一个CellList
friendCellList = new CellList<PlayerDataEntity>(new PlayerCell());
friendCellList.setSelectionModel(new NoSelectionModel<PlayerDataEntity>());我希望传递NoSelectionModel将防止UI对用户选择单元格列表中的项作出反应。但是,用户能够正常地选择元素。我没有正确地应用选择模型吗?
发布于 2012-05-15 11:35:44
来自NoSelectionModel的Javadoc:
--不允许选择的选择模型,但触发选择更改事件。如果希望知道用户何时选择某项,但不希望根据所选内容更新视图,请使用此模型。
这就是它所做的:在标准主题中,这将导致行不再以蓝色高亮显示("cellListSelectedItem“样式类)。但是,它仍将被高亮显示为黄色("cellListKeyboardSelectedItem“样式类)。此外,SelectionChangeEvent仍将被解雇。
若要关闭SelectionChangeEvent,请使用
cellList.setSelectionModel(new NoSelectionModel<String>(),
DefaultSelectionEventManager.<PlayerDataEntity>createWhitelistManager());没有参数的白名单管理器意味着您不能选择任何列。
如果还想关闭“黄色”高亮显示,则应该使用不同的CellList实例实例化CellList.Resources:
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:
.cellListEvenItem {}
.cellListKeyboardSelectedItem {}
.cellListOddItem {}
.cellListSelectedItem {}
.cellListWidget {}https://stackoverflow.com/questions/10590922
复制相似问题