CellListコンポーネントで複数のセルを選択したいと思います。 私はGWTを初めて使いました。誰かが助けてください。 複数選択を行うには、以下のコードをどのように変更すればよいですか?GWT CellListで複数選択が必要
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);
}
}
こんにちは、複数の選択のために以下のコードを試してみましたが、それは_ ** Ctrl ** _キーの長押しでうまくいきました。 ** ** Ctrl ** _ ** Ctrl ** _ –
final MultiSelectionModel selectModel = new MultiSelectionModel ();を押さずに_ **を使用してこの複数選択を行いたいと思います。 \t \t cellList.setSelectionModel(selectModel); \t \t selectModel.addSelectionChangeHandler(新SelectionChangeEvent.Handler(){ \t \t \tます。public void onSelectionChange(SelectionChangeEventイベント){ \t \t \t \tセット= selectModel.getSelectedSet(選択); \t \t \t \t選択(もし! )「+選択され; := NULL){ \t \t \t \t \t //Window.alert("You選択0 \t \t \t} \t \t \t} \t \t})。 –
複数の選択肢のチェックボックス列を追加することをお勧めします。 –