Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to pass the data from database(ODATA) to Json model for using list

Hi all,

This is bala,Currently i am working in a project,In this project i am using Search field here i am getting data from odata(Back end),i need to get the data from database and put that in JSON model.then only i can use the search function.i need code to put the data in Json which is coming from ODATA

Tags:
Former Member
Former Member replied

Hi all,

This is working fine.and thank you for your response,

The code is

In xml view put entity set as "A>/List/results",

onInit : function(){

  oController=this;

  oController2=this;

  var that=this;

  oController.oData1 = new sap.ui.model.odata.ODataModel ("url",true);

  var fnSuccess=function(oData,oResponse)

  {

             var jsonArray ={

            "List":oData

             } 

           

var oJSONModel = new sap.ui.model.json.JSONModel();

sap.ui.getCore().setModel(oJSONModel);

oJSONModel.setData(jsonArray);

oController.getView().setModel(oJSONModel,"A");

}

  oController.oData1.read("/MatSet ",null,null,true,fnSuccess)

// oController.setModel(oJSONModel);

  },

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question