How to add a click Listener to a table's cell in vaadin?

Hasan picture Hasan · Jul 23, 2012 · Viewed 12.1k times · Source

I created a multiselectable table in vaadin, but I can't select only a cell in this table when I click it selects all row.

Is there any way of selecting only a cell of a row ?

Answer

Charles Anthony picture Charles Anthony · Jul 23, 2012

The title of the question doesn't reflect the actual question inside

Is there any way of selecting only a cell of a row ?

No. The whole point of a Vaadin table is to reflect rows of data in a tabular form. Setting a table to selectable keeps track of the itemIds of the selected rows with the table

You might be able to simulate selecting cells by using a ColumnGenerator in the table, and adding a listener to the generated component. Removing the listener may be tricky, however.

Alternatively, you may wish to simply generate components in a GridLayout and keep track of the selected cells yourself.

Ultimately, the approach here really depends upon exacly what you are trying to achieve.