Grid editable inline error

Hi everyone, i am trying the grid with inline editing, using Documentation i have a problem when i update a item, save, then re-update the same item and throws this error Unable to save the ‘ObjectA’ object changes

The object has just been changed by another user or by the system. In order to avoid conflicts or data loss, please reopen the screen and reapply your changes. I suppose because the version fields remains the same. How to handle this case? Thanks

Hi Federico,

Most probably you get this exception because your entity is optimistically locked (has a @Version attribute) and you don’t set the saved entity instance back to the data container.

We’ve just updated the relevant UI sample: https://demo.jmix.io/ui-samples/sample/data-grid-inline-editor, it now describes how to save changes when using DataGrid inline editor. Particularly, take a look at this method:

private void saveChanges(Customer customer) {
    // Save changed entity
    Customer savedCustomer = dataManager.save(customer);
    // Replace the original entity in the data container with the saved one
    customersDc.replaceItem(savedCustomer);
    // Note that if the original entity is merged into DataContext (this is the
    // case when <loader readOnly="false">), the saved instance should be merged too
    notifications.show("Changes saved to the database");
}

The documentation will be updated too.

Let us know if you need further clarification.

Regards,
Konstantin