Michael Kročka
Michael Kročka

Reputation: 665

Header (select all) checkbox does not stay checked

we are using Vaadin 8 and we have a multi select grid. In the header there is a checkbox present which acts as a select / deselect all checkbox. The problem is that the header checkbox does not stay checked after the window is closed. E.g. if the window is opened, the header checkbox is checked -> all other checkboxes are checked, the window is then closed and opened again he header checkbox is unchecked again. Is there a method to manually set the header checkbox value, or any other workaround? We work with a data provider object and upon the button click the selected items are saved, but we have no way of accessing (or we do not know of a way of accessing) the header checkbox.

Upvotes: 1

Views: 263

Answers (1)

Anna Koskinen
Anna Koskinen

Reputation: 1370

The Select All checkbox state is determined through MultiSelectionModelState.allSelected. You can access the model via

MultiSelectionModelImpl<MyPojo> selectionModel = (MultiSelectionModelImpl<MyPojo>) grid.getSelectionModel();

(or using the return value when you set the selection mode).

You can mark the checkbox selected via

selectionModel.selectAll();

or deselected via

selectionModel.deselectAll();

Upvotes: 2

Related Questions