Skip to Content
0

How to Bind Odata in json to combo Box?

Dec 26, 2017 at 01:02 PM

74

avatar image

Hi All,

i am new sap ui5 started developing UI5 app,but stuck at DAta binding in combo box.

DAta is coming from sap server as odata in json format.

Please provide any quick solution where i done wrong??

the XML View

The Odata in JSON in Console.

Thanks

Surya

viewxml.png (5.3 kB)
odata-in-json.png (19.1 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Arjun Biswas Dec 27, 2017 at 04:49 AM
0

Hi surya prakash tanguturi,

Could you try setting your model to the particular view specifically.

Regards,

Arjun Biswas

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Yeah its worked when i attach model to my view.But How can i attach another model to same view???Beacause i am using another json in the same view.

0

Hi surya prakash tanguturi,

Yes, you can attach another model to the same view, by giving the model an alias name.

this.getView().setModel(modelObject); //Sets your default model
this.getView().setModel(modelObject1,"firstModel"); //Sets another model to your view
//To get data from these models :
this.getView().getModel().getData(); //get default model data
this.getView().getModel("firstModel").getData(); //gets data of the second model

Hope this helps,

Regards,

Arjun Biswas

1
avatar image
Former Member
Dec 26, 2017 at 04:29 PM
0

There is little less information in order to comment on this.

Could you please share your manifest file as well.
Would like to the model which is bound to the view.

Also, do you see any error in the console ?

Show 1 Share
10 |10000 characters needed characters left characters exceeded

var sServiceUrl = "proxy/http/122.165.148.177:8000/sap/opu/odata/sap/ZUI5_SURYA_SRV"

var user = "";

var pass = "";

var oModel1 = new sap.ui.model.odata.ODataModel(sServiceUrl,true,user,pass);

var oJsonModel =new sap.ui.model.json.JSONModel(oModel1); oModel1.read("/EmployeeDetailsSet",null,null,true,function(oData,response){ oJsonModel.setData(oData); })

var res = sap.ui.getCore().setModel(oJsonModel);

Above is my contoller.js

i an simply using controller and a view no manifest.json . i want my json to be as a dropdown in combobox.

output.png (5.3 kB)
0