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

Databinding with element count

Hi,

I got a list Item:

itm = new sap.m.ObjectListItem({

title : "Ansprechpartner",

icon:sap.ui.core.IconPool.getIconURI("employee"),

type: "Navigation",

unread : true,

counter: 3,

press: showContacts

});

menuList.addItem(itm);

The List Item should be bind to a model.

Instead of having hardcoded the value "3" I want do have a counter showing the elements under /customer/0/contacts

I there a syntax, how I can do a count, e.g.

counter: {contacts@count},

Thanks

Jens

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Dec 10, 2013 at 06:41 AM

    var actionListItem = new sap.m.ObjectListItem("action",

    {

    title : "{name}",

    icon:sap.ui.core.IconPool.getIconURI("employee"),

    type: "Navigation",

    unread : true,

    counter: "{counter}"

    });

    $.each(data.list, function(i, item) {

    Object.defineProperty(data.list[i], "counter", { get : function(){

    return this.contacts.length; } } );

    });

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 10, 2013 at 04:05 AM

    Hi Jens,

    For this requirement you will have to implement inlinecount to the entity set contacts on the odata side. The Contact Entity Type must also have ContactsCount field to which you will set the inlinecount.

    Then you can directly bind counter : "{ContactsCount}". It will show the count.

    Regards,

    Pruthvi.

    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.