Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 11577

Re: Possibility to save HTML5 data locally on mobile devices

$
0
0

Hi Saubrabh,

 

Reading your other posts it is hard to tell if you are asking the right questions.

 

"I want to know whether it is possible to store the values inside a UI5 table using this particular localStorage object"

 

I will walk you through some simple scenarios.

 

Standard scenario

1. We retrieve OData into an OData Model

2. We bind the Model to the Table

 

this.oModel=newsap.ui.model.odata.ODataModel("../sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT");
oTable.setModel(this.oModel);
oTable.bindRows("/TravelagencyCollection");

How to do we get the data into the local storage

 

1. We retrieve OData into an OData Model

2  When the data is reveived store it in local storage using one of the three techniques above

3. We bind the OData Model to the Table

 

 

this.oModel=newsap.ui.model.odata.ODataModel("../sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT");
this.oModel.read("/TravelagencyCollection", handleSuccess. handleError );
// in the success handler write returned data to local storage
handleSuccess(oData, oResponse) {     this.oStorage.put("TravelagencyCollection", oData.results); //Set Data
} 

oTable.setModel(this.oModel);
oTable.bindRows("/TravelagencyCollection");

 

How do we get the stored data to display on the table

 

1. We retrieve OData using the OData model

2. Connection down,

3. We have data in local storage

4. Create a JSON model from the stored results

5. We bind the JSON Model to the table

 

this.oModel=newsap.ui.model.odata.ODataModel("../sap/opu/sdata/iwfnd/RMTSAMPLEFLIGHT");
this.oModel.read("/TravelagencyCollection", handleSuccess. handleError );
// in the success handler write returned data to local storage
handleError(oError) {    //connection was down    var storedData =this._oStorage.get("TravelagencyCollection");     this.oModel = new sap.ui.model.json.JSONModel();

//im guessing here but
  var jsonData = { "/TravelagencyCollection": storedData };
oModel.setData(jsonData);  //additional formatting required
}
oTable.setModel(this.oModel);
oTable.bindRows("/TravelagencyCollection");

 

Hope it helps.

 

Cheers

John P

 


Viewing all articles
Browse latest Browse all 11577

Trending Articles