cancel
Showing results for 
Search instead for 
Did you mean: 

How to change odata model data with expanded data?

0 Kudos

I have the following odata structrue: appointment, and every appointment has attachments, but the attachments data will be deferred.

Usually I get appointment data with deferred attachments data firstly.Then, I would send a batch request to get all the data for the detail view. One of the requests is to expand attachements data.

The question is how to access the previous odata model and change it with expanded data? The following is my piece of code, but it doesn't work.


// submit the batch reqeust and get the batch response

.......

// access and change the model with expanded data in batch request call back function

var sPath = "/AppointmentSet(guid'" + appointmentID + "')";

var oModel = this. getView().getModel();

oModel.setProperty(sPath, oResponse.data);

oModel.submitChanges();

In Chrome debug mode, I checked that oModel.data didn't change at all.

Any help is appreciated!

B.R.

Yang

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

In simple term, how to refresh the odata model after the batch request?

The batch request doesn't seem to refresh the odata model automatically.

santhu_gowdaz
Active Contributor
0 Kudos

Refer this link

0 Kudos

That is not my scenario!

Normally the odata model will refresh automatically after any explicit odata operation, like read, update, etc. But my scenario is that the data model does not refresh automatically after it sending a batch request. So all the view elements binded to the change data won't resovle at all.

Former Member
0 Kudos

Do you mean oModel.refresh()?

0 Kudos

No. I think I cannot refresh the model that way.

The trick part is that I have to get the expanded attchements data via a batch request. The batch request only give back the response data, and doesn't refresh the model.

santhu_gowdaz
Active Contributor
0 Kudos

u r using oData Model. so after calling again service the previous data will be lost so again u ve to call old service

0 Kudos

No, the previous appointment data won't be lost. I just hope the previous odata model could refresh with expanded data after the batch request. Otherwise, the attchement control could not resolve correctly due to missing data.