Grid Pro: How to store the updated value

Hi All,

On Vaadin 13 Grid Pro component, I have to implement my application that edited and updataed cell value is stored into backend database via JPA repository.
I thought to use value change listner, however Grid Pro component doesn’t have the value change listner.
Anyone know a better way for realize that?

I already got a success to edit itself with Grid Pro component.

Ippei

Here’s an example app with only one item in a GridPro which is edited; this should demonstrate you how it works:

    // sample bean class
    public static class Employee {
        private String title;
        private boolean permanent = false;
        public boolean isPermanent() {
            return permanent;
        }
        public void setPermanent(boolean permanent) {
            this.permanent = permanent;
        }
        public String getTitle() {
            return title;
        }
        public void setTitle(String title) {
            this.title = title;
        }
    }

    public MainView() {
        GridPro<Employee> grid = new GridPro<>();
		// Only one employee is ever created
        Employee employee = new Employee();
        employee.setTitle("foo");
        employee.setPermanent(false);
        grid.setItems(employee);
        grid.addEditColumn(Employee::getTitle)
                .text(new ItemUpdater<Employee, String>() {
                    @Override
                    public void accept(Employee empl, String s) {
                        // update the row object
                        empl.setTitle(s);
                    }
                }).setHeader("Title");
        grid.addEditColumn(Employee::isPermanent)
                .checkbox((empl, checked) -> {
                    // update the row object
                    empl.setPermanent(checked);
                })
                .setHeader("Permanent");
        Button button = new Button("show employee", e -> {
            Notification.show("Title is now: " + employee.getTitle() + ", is permanent?: " + employee.isPermanent());
        });
        add(grid, button);
    }

So you can define how using the editors update the items in the Grid.

Thanks Olli.

It works well that updated value stores into database by to call the repository.saveAndFlush from accept method.

grid.addEditColumn(Employee::getTitle)
                .text(new ItemUpdater<Employee, String>() {
                    @Override
                    public void accept(Employee empl, String s) {
                        // update the row object
                        empl.setTitle(s);
				------>	repository.saveAndFlush( empl );
                    }
                }).setHeader("Title");