Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to extract data from JSONModel data array by index

mhcho
Discoverer
0 Likes
1,124
  • SAP Managed Tags

data.pngDear all,

We are developing SAPUI5 application. We are getting data from Oracle by using JSON data by ASP.net application.

We are able to read the data successfully and the sample program is as follows:

var oTab = this.getView().byId("table");

var isel = oTab.getSelectedIndices();

var oTab2 = this.getView().byId("table2");

var text = oTab.getModel().oData[isel].partNo;

oMod = new sap.ui.model.json.JSONModel("http://localhost:5242/Part?$filter=PartNo eq '" + text + "' & orderby=revision desc");

this.getView().setModel(oMod, "Part");

oTab2.setModel(oMod);

oTab2.bindRows("/");

I am attaching two screen capture files and one of them is the data came out from ASP.net and the other is console log of JSONModel using data from ASP.net.

What I would like to know is how I can extract data from JSONModel.

I have tried to use were

this.getView().getModel("Part").getProperty("/"), some other function calls.

But It was not successful to extract the data from oMod.

Can someone help me to extract the data in JSONModel ?

jsonmodel.png

1 REPLY 1
Read only

sgonzmot
Participant
0 Likes
1,080
  • SAP Managed Tags

Hi mhcho,

In my case I normaly use:

oEvent.getParameter("listItem").getBindingContext().getObject();

or in case for multiple selection I use:

const selectedItems = this.getView().byId("oModel").getSelectedItems();

selectedItems[i].getBindingContext("oModel").getProperty("key");

I attach a link that adds another option: link

I hope it helps.

Best regards!