我想設置一個CellList,以便單擊一行將切換選擇。這樣可以選擇多行而不需要按住Ctrl鍵。GWT CellList單擊以切換選擇(多選)
我需要更改以使其工作?
class ToggleEventTranslator<T> implements DefaultSelectionEventManager.EventTranslator<T> {
@Override
public boolean clearCurrentSelection(final CellPreviewEvent<T> event) {
return false;
}
@Override
public SelectAction translateSelectionEvent(final CellPreviewEvent<T> event) {
return SelectAction.TOGGLE;
}
}
MultiSelectionModel<ObjProxy> multiSelectionModel = new MultiSelectionModel<ObjProxy>();
ocjCellList.setSelectionModel(multiSelectionModel, DefaultSelectionEventManager
.<ObjProxy> createCustomManager(new ToggleEventTranslator<ObjProxy>()));
'selectModel'的定義是什麼樣的? – Carl
我已經使用CellList嘗試了這段代碼,並且它沒有啓用多個項目進行選擇。有更多的實施? – Carl
良好的捕獲,使用這個選擇模型應該可以選擇多個項目。 private final MultiSelectionModel selectModel = new MultiSelectionModel (); –