openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Issue with sap.m.table.removeItem

Open jjteran opened this issue 11 years ago • 6 comments

Hello experts,

I'm using removeItem method to delete a row in my sap.m.table with OData model v2 (sapui5 version 1.26.10) because I'm using deferred batch with change set, but it's happening when I delete an item (with removeItem method) in one context, if I change to another context the item in the same table have disappear too, I have 2 entities with 1 to M relationship, so for example I have 2 record in principal entity, if I navegate to the table with dependant data (M table), and remove an item, let's suppose we had 3 records and delete 1, now we have 2 records, when I go to the another record in the principal entity and navigate to the dependant data and if I had 3 records, only appear 2, like if I was deleted in both parts, when this is not true.

Please your help, if I'm using the wrong method kindly tell me how to achieve refresh bindings without commiting to the backend when using batch requests.

Thank you very much.

jjteran avatar Apr 28 '15 15:04 jjteran

Hi jjteran,

thanks for your ticket. I am not sure that I understood the issue correct. What would you like to achieve? If I get you right, you would like to remove an item in the table but not remove it from the model, is this correct?

It would be great if you can provide a minimal example with JSBin.

Kind regards, Janina

blaesius avatar Apr 29 '15 07:04 blaesius

Hello Janina,

Sorry if I could not be clear, I change my question a little bit, I'm using odata model v2, sapui5 1.26.10, and I have a table (sap.m.table), I'm using deffered batch request, but I'm having many problems refreshing my table when I delete/create/modify records, I need for example delete a record from the model (oDataModel.remove) when press delete button, but nothing happens visually (the record remains in my table) until i commit with submitChanges() method in my save button code.

I am using two way binding.

Thank you very much in advanced.

Best regards.

Jhon Jairo Teran.

jjteran avatar Apr 29 '15 18:04 jjteran

Hi Jhon, as TwoWay binding is not yet supported for creating/deleting entities at client side, this is exactly how it should work. You have to submit your changes first and do a refresh of the table binding afterwards. The refresh is normally done automatically. BR, Jan

loginger avatar May 04 '15 08:05 loginger

Thank you Jan, this has been very clear for me, I appreciate your help in that sense, please one last thing, and I apologize for the inconveniences: right now what alternatives do I have to get this to work, with or without using TwoWay binding, please kindly advise me, i read a post by hschaefer123 user (https://github.com/SAP/openui5/issues/286#issuecomment-97102821) where he said that he could do this using TwoWay binding with autoupdating the binding (using a workaround or something like that):

"This way i was able to control insert/updates/deletions (with auto updating the binding)"

But I'll try this without any success.

Again I appreciate all your collaboration.

Best regards.

Jhon Jairo Teran.

jjteran avatar May 04 '15 13:05 jjteran

Hi Jhon, that's exactly what I said. The refresh is done with the automatic refresh feature (refreshAfterChange). It is turned on per default. You have to submit your changes first. The Model identifies the bindings that needs a refresh and trigger a GET within the same $batch request. Without the refresh you can't see the created/removed entities on your view. This should work out of the box with the v2 ODataModel. BR, Jan

loginger avatar May 05 '15 09:05 loginger

Hi Jan, an alternative it could be pass odata model to a json model to get this to work?, I mean when reading pass the odata model to json model, and when saving pass json model to a odata model using create/update/remove.

Kind regards.

Jhon Jairo Teran.

jjteran avatar May 08 '15 12:05 jjteran