Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Grid in MultiSelect mode: Is there a way to disable the checkbox based on r
Hi All,
I have a grid that allows multiple selections. I'd like to disable the selection of some rows by disabling the checkbox. Is there an easy way to do this?
Thanks in advance for your help.
Hi Rebecca,
Using the latest vaadin alpha version (currently 7.6.0.alpha5) you can actually extend and modify the existing SelectionModel implementations. You can override the client-side to provide a renderer that is aware of the data and can prevent some rows from being selected, but this is actually pretty tricky to actually implement.
First of all you need to make a named override of the server-side part of the SelectionModel. For example
public class MySelectionModel extends MultiSelectionModel ..
that overrides the method generateData to write a boolean telling if this row can be selected to the actual row data.
Then you neeed a corresponding client-side connector
@Connect(MySelectionModel.class)
public MySelectionModelConnector extends MultiSelectionModelConnector
In this connector you need to override the method createSelectionModel and use you own implemention (most likely extends the client-side implementation of MultiSelectionModel from the MultiSelectionModelConnector) and in that implementation you need to provide a customized version of MultiSelectionRenderer that disables the checkboxes when needed.
This is the basic idea on extending a selection model starting from Vaadin 7.6.0.alpha5. Before that, you need more client-side hacks to provide the similar functionality.
//Teemu
Thanks Teemu. We are still on 7.4.7. Will give this a try when we have a chance to upgrade.
Rebecca