Checkbox Checked Event in DataGrid?

Hello all. We are using the DataGrid in Multi Selection Mode and need to disable a button on the page unless a user has at least one or more items selected (checked).
I have looked at the grid’s addItemClickListener and don’t see where it tells me when an item has been checked. The call back fires when the Item or entire row has been selected but not when a checkbox by itself has been checked. If I could get the current total number of items checked in addItemClickListener, that would work as well.
How can I achieve this?

Thank you,

  • Jon

Hello all. Just a refresh. Is there any way to know when a grid’s checkbox has been checked?
Thank you so much.



Did you try addValueChangedListener on the grid ?

It’s fired when an item is selected.

grid.asMultiSelect().addValueChangeListener(event -> {
	String message = String.format("Selection changed from %s to %s",
		event.getOldValue(), event.getValue());

Thanks Jean-Christophe! This is perfect.
I dug through the whole grid object model but didn’t know MultiSelect and SingleSelect had listeners off of them.
Super handy to know now.
Thanks so much!

  • Jon