Jmix 2.3.1
How can I commit the DataGrid inline editing changes to database? They are not being saved in database automatically.
Jmix 2.3.1
How can I commit the DataGrid inline editing changes to database? They are not being saved in database automatically.
Hello!
You can use DataManager
and saveListener
in case you have collection container or view’s DataContext
that is read only.
See DataContext :: Jmix Documentation):
<data readOnly="true">
...
</data>
<loader id="myDl" readOnly="true">
You should subscribe to saveListener
and then save entity instance:
<dataGrid id="usersDataGrid"
editorBuffered="true" ...>
<columns>
....
<editorActionsColumn>
<editButton icon="EDIT"/>
<saveButton icon="CHECK"/>
</editorActionsColumn>
</columns>
</dataGrid>
@Autowired
private DataManager dataManager;
@Install(to = "usersDataGrid.@editor", subject = "saveListener")
private void usersDataGridEditorSaveListener(final EditorSaveEvent<User> event) {
dataManager.save(event.getItem());
}
If you want to use an inline editor in detail views, consider the relationship of this entity with others in the detail view. And, probably, not to use immediate entity saving but instead rely on DataContext saving.