Skip to Content
0

sap ui5 binding problem with view

Nov 14, 2017 at 02:34 PM

61

avatar image

hi all

i am using xml view with and it is like this

<content>

<List id="list1" items="{/results}">

<ObjectListItem id="LIST_ITEM" title="{desc}"> </ObjectListItem>

</list>

<content>

-------------------------------------------------------

and js code like this

var sServiceUrl="url";

var oModel = sap.ui.model.odata.ODataModel( sServiceUrl,{ json:true, loadMetadataAsync: true});

var oJsonmodel = sap.ui.model.json.JSONModel();

oModel.read("url",nul,null,true,function(odata1,response){

oJsonmodel = new sap.ui.model.json.JSONModel(odata1);

sap.ui.getCore().setModel(oJsonmodel,, "jsonid");

console.log(odata1);

console.log(oJsonmodel);console.log(response);}var b = this.byId("LIST_ITEM");var list2 = this.byId("list1");list2.setModel(sap.ui.getcore().getModel("jsonid");list2.bindAggregation("items","/results",b);}--------------------------------------------------------------------------------------as all console shows output but list not update with outputplease correct it or suggest itthanks in advance.
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Jamie Cawley
Nov 14, 2017 at 04:38 PM
0

Not sure I understand why you have an odata and a json model, should be able to just use the odata model. Either way you are aliasing the model with

sap.ui.getCore().setModel(oJsonmodel,, "jsonid");

in which you have two commas between the parameters that you need to fix. In the view you need to provide the alias in the bindings

{jsonid>/results} and {jsonid>desc}

Regards,

Jamie

Share
10 |10000 characters needed characters left characters exceeded
Archit Wahi Nov 15, 2017 at 01:56 AM
0

Hi Jamie

I put {jsonid>/results} and {jsonid>/desc} but still no output

Also output for oJsonmodel in console

Constructor

--oData--results-0: object-desc

Share
10 |10000 characters needed characters left characters exceeded
Archit Wahi Nov 15, 2017 at 01:59 AM
0

And how to do it with odata

Share
10 |10000 characters needed characters left characters exceeded
Archit Wahi Nov 15, 2017 at 02:03 AM
0

Also I tried to put

Console.log(sap.ui.getCore().getModel("jsonid");

Output is undefined

Share
10 |10000 characters needed characters left characters exceeded