I would like to add new entity using form and save it after filling all required data. Because this objects are complex I don't want to fill data directly on list.
Only way that I found to create new entity when using OData V4 is by use of method Create on sap.ui.model.odata.v4.ODataListBinding. example from openUI5 documentation
Unfortunately I'm not able to bind to this created entity from other View or even Form on the same view.
Maybe this is wrong approach. Does anybody know any solution/example of creating new entity without aggregation binding with OData V4?
My solution for this issue was to create list biding in controller like this:
var oItemTemplate = new sap.m.ColumnListItem();
this._oBindList = new sap.m.List({
items: {
path: "/somePath",
parameters: {
$$operationMode: "Server",
$$updateGroupId: "SOME_GROUP"
},
length: 1,
template: oItemTemplate
}
});
this.getView().addDependent(this._oBindList);
Then I bind JSONModel with appropriate structure to View. When user click on Add I just call Create method on this list binding with data from JSONModel
var newData = this.getView().getModel("ModelName").getData();
var oJsonData = JSON.parse(newData);
var oBinding = this._oBindList.getBinding("items");
oBinding.create(oJsonData);