Skip to Content
author's profile photo Former Member
Former Member

Problem with sap.m.List binding

Dear users & experts,

I am using sap.m.List in my sapui5 mobile application, where am facing a trouble in binding the list with model. I can get the value from OData service, but I can see only the last value in all the five items in the list.

Example: If in the actual aggregation the values are like "A, B, C, D, E" I can see in the list like "E, E, E, E, E" .

I am not sure where am missing or doing wrong, below is the code implemented. Could you please check the same and let me update the fix wat I missed here. Thank you.

Please also update me if you need any additional info.

var oListStandardNoImageNoHeader = new sap.m.List({

inset : false

});

var itemTemplate = new sap.m.StandardListItem({

title : "{HandlingUnit}",

icon: "icons/yellow_sign_micro.png",

description: "Test Value",

iconInset: false

});

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 08, 2013 at 12:17 PM

    Hello Rajesh,

    You can try this with JSONModel instead.

    You can convert any OData service into JSON service by adding $format=json to the service URL. And then you can use the JSON model instead of OData model.

    Here is a sample code explaining how to use JSON Model. Hope this helps.

    var oListStandardNoImageNoHeader = new sap.m.List({ inset : false });

    var itemTemplate = new sap.m.StandardListItem({

    title : "{ProductID}",

    iconInset: false

    });

    var oModel = new sap.ui.model.json.JSONModel(“http://services.odata.org/Northwind/Northwind.svc/Products?$format=json");

    oListStandardNoImageNoHeader.setModel(oModel);

    oListStandardNoImageNoHeader.bindAggregation(“Products","/ProductID" , itemTemplate);

    Regards,

    Guru.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 29, 2015 at 04:21 AM

    Hi bit late but just ran into this problem as well. Let me explain why this happened for us,

    There is nothing wrong with using the oData Model rather than JSON model, both work.

    The problem I found was with the entity model, in particular, the entity key of each item you are trying to bind was either not unique or there was a repeated entity key ( same value ) in the oData response ( fundamentally this means there are no unique entities in the collection ).

    What this meant for the list binding is that it cannot determine a unique entry for each list item, hence you see ( in this case ) the repeated "E", "E", "E", "E".

    The number of entries is correct, but the display binding is constantly looking at 1 key. This is exactly what happened in our case, someone had put a Business Partner as they key of the related entity set, therefore you get 5 entities with the same key. Produces this symptom.

    In the case above, you have defined a key of :

    1. <PropertyRef Name="PurchaseOrder" />
    2. <PropertyRef Name="Delivery" />


    The result set for HUList:


    1. "PurchaseOrder":"",
    2. "Delivery":"0182649166",
    3. "HandlingUnit":"0027178557",
    4. "HUList":
    5. "PurchaseOrder":"",
    6. "Delivery":"0182649166",
    7. "HandlingUnit":"0027178558",
    8. "HUList":

    Hope this helps anyone else that comes across this problem, you can absolutely use oData Model instead of JSON model if you wish.

    Cheers

    Leigh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 31, 2013 at 05:52 PM

    Hi Rajesh,

    Please find below working version of your code

    http://jsbin.com/uxokuc/55/edit

    If you still face issue post your json data and code used for binding.

    Thanks and Regards,Venkatesh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 31, 2013 at 06:03 PM

    How are you binding the aggregation?

    Here's an example based on the code you showed, with a shot of what the List looks like. I've used an JSON model to make it easier to show.

            var data = {            records: [                { HandlingUnit: "Apple" },                { HandlingUnit: "Banana" },                { HandlingUnit: "Carrot" }            ]        };        var oListStandardNoImageNoHeader = new sap.m.List({                inset : false            });            var itemTemplate = new sap.m.StandardListItem({                title : "{HandlingUnit}",                icon: "sap-icon://accept",                description: "Test Value",                iconInset: false            });       oListStandardNoImageNoHeader.setModel(            new sap.ui.model.json.JSONModel(data)        );        oListStandardNoImageNoHeader.bindAggregation(            "items",            "/records",            itemTemplate        );        oListStandardNoImageNoHeader.placeAt("content");

    I bound the model to the list, bound the aggregation using your template, (and changed the icon) and it looks like this:

    HTH

    dj


    abc.png (4.9 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 03, 2013 at 08:01 AM

    Hi Rajesh,

    I am also new to SAPUI5. I am trying to solve this Issue.

    I have done one mobile application using odata model and I got the result with different PO numbers.

    In that I binding the service like below.

    this.poList = new sap.m.List({});

    this.poList .bindAggregation( "items", { path : "/Po_Headers",

    template : new sap.m.StandardListItem( {

    title : '{Ponumber}',

    type : sap.m.ListType.Navigation,

    description : "{WiText}",

    tap : [ oController.polListTap, oController ]

    })

    });

    I feel happy if it is helpful for you.

    Thanks&Regards

    Sridevi

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.