0

CellList コンポーネントで複数のセルを選択したいと考えています。私はGWTが初めてです。誰か助けてください。複数選択するには、以下のコードをどのように変更すればよいですか?

public class HelloWorld implements EntryPoint {
private static final List<String> DAYS = Arrays.asList("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
        "Friday", "Saturday");

public void onModuleLoad() {
    // Create a cell to render each value.
    TextCell textCell = new TextCell();

    // Create a CellList that uses the cell.
    CellList<String> cellList = new CellList<String>(textCell);
    cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);

    // Add a selection model to handle user selection.
    final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>();
    cellList.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            String selected = selectionModel.getSelectedObject();
            if (selected != null) {
                // Window.alert("You selected: " + selected);
            }
        }
    });

    cellList.setRowCount(DAYS.size(), true);

    // Push the data into the widget.
    cellList.setRowData(0, DAYS);

    // Add it to the root panel.
    RootPanel.get("gwtCellListBox").add(cellList);
}
}
4

2 に答える 2

1

まず、 が必要ですMultiSelectionModel。次に、Ctrl キーを押したままにしたい場合は、常に返すカスタムで aDefaultSelectionEventManagerを使用します。CellPreviewEvent.HandlerEventTranslatorTOGGLEfalse

于 2016-06-30T18:38:29.693 に答える