Openui5: Bound Table not updated after createEntry on ODataModelv2 with deferred group

Created on 22 Feb 2019  路  7Comments  路  Source: SAP/openui5

Prerequisites:

  • An XML view with a sap.m.Table bound to an entity set of a ODataModel v2.
  • Two-way-binding activated
  • Deferred group = 'groupId'
  • Change set = 'changeSetId'

Reproduction steps:

  1. Add a new entity to the OData model using oModel.createEntry({groupId: 'groupId', properties: ...})

What is the expected result?

  • The bound table should show the newly created entry.

What happens instead?

  • The bound table does not show the newly created entry.

I can see in the ODataModel that the entry exists with a local id and properties are set correctly. But my table is not updated to reflect the data. Only after calling oModel.submitChanges() on the ODataModel, which goes to the backend OData service, these changes will show up in the table.

in progress

Most helpful comment

Plus one. We are having the exact same problem in our development right now, and searching through SAP Blogs, questions and archives show that several people have been facing this for years. Having to throw data from ODataModel to JSONModel just to be able to do these operations feels wrong.

All 7 comments

Hi @one-github,

calling oModel.createEntry doesn't let the ListBinding fire a change event, therefore, the UI isn't updated. In order to make this feature available, there are lots of open questions to be answered. For example, at which position the newly created entry should be displayed on the UI after the createEntry is called? The sorting of the new entry can only be decided by the backend after the response of submitChanges call is finished. Before this call, the position of the new item can't be decided. If you combine this with the "growing" feature of the sap.m.Table, it's getting even more complicated.

However, this is definitely a feature which is needed for some scenarios. I will contact the product management of UI5 and see whether this is an urgent feature from the whole product perspective. But I would say that the feature won't be implemented in a short term and you need to put more time for the expected delivery date of this feature.

I will post another comment after I get feedback from product management.

Best regards,
Jiawei

Hi @stopcoder

Thanks for looking into this issue. The app we are trying to implement is a master-detail layout with a 1:n association in the detail. We looked into first saving the data in draft backend database tables and only write them to the real database tables after the save button has been pressed. Unfortunately this workaround is very cumbersome, complex and error-prone.

I know of multiple UI5 developer teams therefore using JSON models on the client and synchronizing changes to the backend OData services to work around this issue - it's the way we are going forward now. But like for the backend draft-tables (as outlined above) it is also very error-prone to implement.

Best regards,
Nicola

Plus one. We are having the exact same problem in our development right now, and searching through SAP Blogs, questions and archives show that several people have been facing this for years. Having to throw data from ODataModel to JSONModel just to be able to do these operations feels wrong.

Same here. I need to create temporary records with specific dates mixed with existing (persisted) records which can be edited by a user afterwards. The changes by the user can be canceled completely and then the temporary records should not be persisted at all. So they need to go into a deferred batch - all that works except that a sap.ui.table.table does not show the temporary records (only the already persisted ones). Tried to invalidate the table and all kinds of refresh/updateBinding methods but the records create with createEntry do not show up (only the persisted records coming from the DB via Odata).

+3, We are also facing the exact same issue in our development, were we try to maintain the back end object through a table in UI5. Reading through the blogs felt that, adding a new row at top of the table is commonly asked for and the same our requirement.

Hi @one-github , @lucasheim , @rauar and @i328935 ,

the functionality you request is available with the OData V4 Model, please see API documentation: sap.ui.model.odata.v4.ODataListBinding.create.
In case your service can be exposed also as OData V4 and all required features are available with OData V4 (see the restriction at the beginning of the documentation on the OData V4 Model) I recommend to go with the OData V4 Model.

As to enhancing the OData V2 Model, I have rather bad news. The enhancement will be rather complicated and thus time consuming. In the next months, probably the whole year, we would not have time to work on this requirement.

Best regards
Mathias.

Was this page helpful?
0 / 5 - 0 ratings