Skip to Content

sap ui5 binding problem with view

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.
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Nov 14, 2017 at 04:38 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 15, 2017 at 01:56 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 15, 2017 at 01:59 AM

    And how to do it with odata

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 15, 2017 at 02:03 AM

    Also I tried to put

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

    Output is undefined

    Add comment
    10|10000 characters needed characters exceeded