Vaadin 8: Grid - Fetch row values when button in the grid is clicked

Hello,

I have a Grid that has a button in one of the columns for every row, I want to fetch the entire row value when the button is clicked so that I can store it somewhere else than the bean from where the grid sources it’s data.

How can I fetch the row values when the button is clicked? And after it is clicked I want to “disable” the button.

Thanks

Here’s one example how to refresh a Grid row on button click:


See the full sample on vaadinfiddle.com

This kind of refreshing can be necessary if something modifies the underlying beans without dataprovider’s knowledge.

To be able to disable the button on click, you could replace the ButtonRenderer with a
ComponentRenderer
with Buttons and in the ClickListener use the Button’s
API to disable
the button.

Remember that when using a ComponentRenderer you should consider that using it might lead into performance problems.

It’s up to your imagination what you do in the ButtonRenderer’s RendererClickListener.click method. You can e.g. read the content of all the visible columns and create a new bean based on those:

Person clone = new Person();
clone.setFirstName(e.getItem().getFName());
clone.setLastName( e.getItem().getLName());

Service.doSomathing(clone);

Hi Jonni,

Thanks for your reply, I am not trying to refresh the row. Basically, when I click the button, I want to fetch the row values and store them in a new Bean - which is not related to the Grid in any way. Will the above solution that you have sent work for what I am trying to achieve?

Thanks

Perfect! Thanks a lot !