cancel
Showing results for 
Search instead for 
Did you mean: 

How to set null for 'mChangedEntities' in V2 ODataModel with Two-Way binding?

former_member213400
Active Participant
0 Kudos

Hello Folks,

I am using V2 ODataModel with Two-Way binding for my sap.m.Table. Table contains one editable column.

So whatever edited that data to be updated to back-end system. but the catch is after editing the items I am not updating. though I am not updating Model is holding the changed values not from the server. To understand the issue we troubleshooted it. What we found is, since we are using Two-Way binding, model is holding the changed Entities.

Could you please guide us, how can I nullify the Changed Entities array from Model.

Thanks in Advance.

Best Regards, Kiran.

former_member213400
Active Participant
0 Kudos

Hello Folks,

Can anyone have idea about this? kindly let us know how to clear changed entities from ODataModel V2.

Thanks.

Accepted Solutions (0)

Answers (3)

Answers (3)

Yifan
Advisor
Advisor
0 Kudos

oModel.resetChanges([this._sEntity]);

former_member213400
Active Participant
0 Kudos

Thank you jberthe.

Yes correct, As Mahesh said "this.getView().byId("idTab").getModel().resetChanges();" this is working for me but I want exact path.

maheshkumar.palavalli as per your given snippet what exactly I should give in the "sPath1"

I am trying as below, but its not working as I expected.

xPath1 = "/entityset". what shall I replace with "1". What is the meaning of '1'.

Here is my expectation,

I have OData V2 model with Two way binding. And in that 3 entitysets are there all 3 are get_entity_sets only. out of 3, 1 I am using for edit. I want reset the changes of that particular 1 entityset not for all.

Thanks in Advance.

maheshpalavalli
Active Contributor
0 Kudos

Hi Kiran VK,

Please check my comment once.. "1" means path. Path is a regular odata path.. eg. If my entiyname is "Customers" and customer id is "AFKJ" the path will be /Customers(id='AFKJ').

You can google or go through the sap ui5 documentations, tutorials or odata related tutorials for this as it is a basic one.

BR,

Mahesh

maheshpalavalli
Active Contributor
0 Kudos

Hi Kiran VK,

If I understand you correctly, you want to clear out all the changes that you performed in the odata model data, if yes use the below method.

https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/resetChanges

BR
Mahesh

former_member213400
Active Participant

Thank you Mahesh.

after adding below piece of code I am able to clear the changed entities from Model.

this.getView().byId("idTab").getModel().resetChanges();

But I am unable to figure it out how to pass the sPath as a Array for resetChanges method.

If you have any ide about this kindly help me.

maheshpalavalli
Active Contributor
0 Kudos

Hi Kiran VK

it should be as below.


// sPath1 = "/entitySet(1)";
aPaths = [sPath1, sPath2];
resetChanges(aPaths)

BR,

Mahesh

Joseph_BERTHE
Active Contributor
0 Kudos

or just

oData.resetChanges();
maheshpalavalli
Active Contributor
0 Kudos

Joseph BERTHE It seems that the code you mentioned already worked for him.. I think Kiran VK wants to clear specific paths.