Skip to content

SelectAllCheckBoxVisibility.HIDDEN is not possible #30

@yoshie82

Description

@yoshie82
        // common grid with public setSelectionModel method
        CustomGrid g = new CustomGrid();
        g.setItems("text1", "text2");
        g.addColumn(c -> c).setSortable(true);

        TableSelectionModel<String> model = new TableSelectionModel<>();
        model.setMode(TableSelectionState.TableSelectionMode.SHIFT);
        model.setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility.HIDDEN);
        g.setSelectionModel(model);

Crashes when selecting an item, because MultiSelectionModelImpl#verifyUserCanSelectAll throws an IllegalStateException on selectAll/deselectAll from client.

Using SelectAllCheckBoxVisibility.VISIBLE does not work properly with Vaadin 8.5.1, because TableSelectionModelConnector#initSelectionModel creates a common MultiSelectionModel and overwrites it with a CustomSelectionModel.

The problem is, that com.vaadin.client.widgets.Grid#setSelectColumnRenderer initially creates a HeaderClickHandler.
If you click on the first column for sorting, all items are selected.

Fix is quite simple:
do not overwrite initSelectionModel() in TableSelectionModelConnector. Overwrite createSelectionModel()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions