Skip to Content
-1

SAPUI5: Get modified values from UI. The concept was driven using oData

Dec 05, 2017 at 06:44 AM

68

avatar image
Former Member

Currently i was doing SAPUI5 a self study. I used SAPUI5 Explored as reference and replicate the functionality in HanahStudio using the mockdata. But, there was an issue encountered when implementing it using ODATA in edit mode. I can not get the modified data in the UI table as the front end system will always triggered the back end and repopulate everything.

Failed steps:

(a) I also do the debugging to check if the modification has been carry over to back end and there were none.

(b) Check also the values before and after triggering the back end. The result was getting the old data.

CODING MADE IN HANAH STUDIO

CONTROLLER

INITIALIZATION FUNCTION:
this.oModel = new sap.ui.model.odata.ODataModel(url);	
this.getView().setModel(this.oModel);
this.oTable = this.getView().byId("idProductsTable");
 

ONSAVE FUNCTION

* CHECK table value before triggering the ODAta
RESULT Still i can not get the modified data.
var oTable = this.getView().byId("idProductsTable");
var	aModel = oTable.getModel();
var oData = aModel.oData;
console.log(oData);

*TRIGGERING THE BACK END
this.rebindTable(this.oReadOnlyTemplate, "Navigation");

VIEW

<Table id="idProductsTable" growing="true" growingThreshold="10" mode="MultiSelect">

Questions

1. How can we retrieve the changes in the UI table? Any suggestion and recommendation on how to retrieved the modified data.

Thank you in advance.

sapui5-issue.png (178.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Dec 05, 2017 at 07:00 AM
0

Hi Choco Relacion,

Could you refresh your model data after your update function has been executed in your back end OData. Use the foll. code :

your_model_object.refresh(true);

Hope this helps,

Regards,

Soumya M

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

Hi Former Member, Thank you for your response. The modification i made in the UI was reset to its original value and did not achieved our goal in retrieving the modified data.

// to check if we can get the changes in the UI view.
this.oModel.refresh(true); // suggested code <----
var oTable = this.getView().byId("idProductsTable");
var	aModel = oTable.getModel();
var	aItems = oTable.getItems();
var oData = aModel.oData;
console.log(oData);
///
this.rebindTable(this.oReadOnlyTemplate, "Navigation");
0
Former Member

If you are using oData It should refresh.

0
Former Member

Hi Former Member , good day. Yes you are correct the data was refreshed. But the issue I encountered is to retrieved modified entries from UI view. Currently i was not getting it. :( hoping you have codes that will get the modified values. I also tried getCore().values it was deprecated. :(

Btw, appreciate your help. :) Thank you.

0
Former Member

in order for us to visualize. Kindly see screen shot below. Thank you in advance. I believe you have stack knowledge mate. :D

ui2.png (97.6 kB)
0