Master-detail inline editor auto saving

I have a master-detail relationship between two entities and I want to use the inline-editor of the datagrid in order to allow users manage detail entities. In addition to that, the detail entities should be automatically saved when the editor is closed.
Trying to implement this kind of functionality, I’ve realized that the in-line editor has a different behavior compared to the editor screen. In order to achieve auto-save I’ve consulted the following link: Master-detail auto save. In this case, the auto-save is working properly when an editor screen is used instead of the in-line editor. I’ve also noticed that in the datagrid documentation there is a section saying for the in-line editor that The changes are committed to the data source or data container only. The logic to save these changes in the database should be added separately.
Based on the above, I would like to ask you how I could save automatically in the database an entity that is created / modified using the datagrid’s in-line editor.



You can subscribe to DataGrid.EditorPostCommitEvent and then commit entity using DataManager:

private DataManager dataManager;

public void onOrderLinesTableEditorPostCommit(DataGrid.EditorPostCommitEvent<OrderLine> event) {

Note that the code above will not work if DataGrid uses a nested container because nested entities should be committed with the master entity.

Thank you for your reply. I tried your approach but it didn’t work. So, I had to use the following code to make it work:

journalLinesTable.addEditorPostCommitListener(editorPostCommitEvent -> {