문제

So I have this piece of code which is almost exactly the same on the GWT Showcase

selectionModel = new SingleSelectionModel<T>(keyProvider);
cellTable.setSelectionModel(selectionModel);

selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
    public void onSelectionChange(SelectionChangeEvent event) {
        selectedRow = ((SingleSelectionModel<T>).selectionModel)
                .getSelectedObject();

    });

Column<T, Boolean> checkColumn = new Column<T, Boolean>(new CheckboxCell(true, false)) {
            @Override
            public Boolean getValue(T object) {
                return cellTable.getSelectionModel().isSelected(object);
            }
        };
        cellTable.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));

The problem is, when I uncheck the checkbox the SelectionChangeEvent doesn't handle it. The only instance the onSelectionChange is being called, is when I select another record, but deselecting a record doesn't invoke this method.

any help?

도움이 되었습니까?

해결책

You forgot to add DefaultSelectionEventManager i guess.

Change this line

cellTable.setSelectionModel(selectionModel);

to

cellTable.setSelectionModel(selectionModel,
                     DefaultSelectionEventManager.<T> createCheckboxManager());
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top