Skip to Content
0

Adding multiple lines in sap.m.Table with deferred request groups

Aug 25, 2017 at 12:17 PM

70

avatar image
Former Member

Hi Experts,

I have implemented a very simple app for testing purposes with a simple responsive table containing Usernames and E-Mail Addresses:

The controller logic is very simple, too. It just contains the button event handlers.

The table data is coming from an ABAP Back-End and I used an Odata Model with Two-Way binding to bind the list. When updating single properties of the existing lines (e.g. E-Mail Address) the Back-End update works fine. My Save Button Event handler simply submits all changes (see listing above). Now I want to add several lines at once and submit them all together. No Record in the back-end can be created before at least the key field "Username" was entered by the user. When pressing the "Add" button my logic actually adds new lines:

When I enter new data in these new lines and submit the changes everything is persisted correctly. But: If I apply any changes to the old lines (originally coming from the BE) the lines vanish. I did some debugging and the model update caused by the changes of the existing lines triggers a refresh of the list binding of the table. All table lines that did not come originally from the BE are removed. The same happens when I change the odata service to One-Way Binding and I call any setProperty Method at the model. So, it's not an issue with the Two-Way Binding.

Does anyone have an idea how to overcome this issue?

Regards

Tobias

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Jun Wu Aug 25, 2017 at 12:39 PM
0

directly adding a line to the table is not supported by odatamodel, if my memory is right.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Jun,

Does that actually mean I have to create a single entity in back-end line by line?

Regards

Tobias

0
Sharath M G Aug 25, 2017 at 04:33 PM
0

To facilitate easier handling of data, load the oData data to a local JSON model.

Manage the local JSON model to add multiple entries. Validate user input and prepare the JSON which is to be updated to backend.

On Save, push the local JSOn model by passing it to the oData service which updates the data.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Sharath M G,

that was exactly my thought, too. I just didn't want to mention that in my initial post to maybe get different approaches. The main problem with that in my productive App (not the app I showed above) is that I am using a Smart Table control. It's heavily based on OData metadata and I am not sure if I can get it working with JSON Model. Moreover, this apporach can be quite cumbersome because I need to keep track of all changes. I exactly need to know which records were created/deleted/changed to know which OData Method needs to be called.

Regards

Tobias

0