Add new row on click button event -Vaadin 14

Hello! I want to add a new row to my grid when I click a button and after this to refresh the grid. How can I do this? (P.s: my grid doesnt have a bean type) Thanks!

This depends a bit on what kind of DataProvider you use, but the basic idea is to add the new item to the backing dataset and the call grid.getDataProvider().refreshAll();.

Olli Tietäväinen:
This depends a bit on what kind of DataProvider you use, but the basic idea is to add the new item to the backing dataset and the call grid.getDataProvider().refreshAll();.

Thank you for your response! Each row in my grid is an arraylist < object>. What I want to do is to add a new empty row in the grid and for each column which type is string/number to have in this new row attached textfields where the client will introduce data and then click save/ enter to append the new row to the grid. I found something like this in grid pro component, but can I do the same things with grid?

Thanks!

You can still use an editor row in non-pro Grid, but its behavior is a bit different from Grid Pro. Check the examples here: https://vaadin.com/components/vaadin-grid/ (go to Examples → Grid Editor, make sure Java is selected). Otherwise, same logic still applies: you add a new item into the DataProvider’s dataset and call refreshAll on the DataProvider.

Olli Tietäväinen:
You can still use an editor row in non-pro Grid, but its behavior is a bit different from Grid Pro. Check the examples here: https://vaadin.com/components/vaadin-grid/ (go to Examples → Grid Editor, make sure Java is selected). Otherwise, same logic still applies: you add a new item into the DataProvider’s dataset and call refreshAll on the DataProvider.

Thank you!