Skip to Content

SAPUI5 List Bind Aggregation get Value of the list

Dear SAPUI5 Gurus,

I have list and I am using bindaggregation to bind my model data. below is my code.

<code>this.oList =this.byId("list");
this.oListItem =this.byId("MAIN_LIST_ITEM").clone();
this.oList.bindAggregation("items",{path:'/myListSet',template:this.oListItem, filters:this.searchFilters,});
this.registerMasterListBind(this.oList); console.log("firststatus"+this.oListItem.getFirstStatus().getText());}

My requirement is to manipulate the value of the firststatus, Fristly I am trying to get the value with the below line and unfortunately it is diplaying null value. Can someone advise how to get the value of the firststatus?


Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Sep 18, 2018 at 08:02 PM

    You would need to get the items aggregation first which returns an array. For the first item...


    Maybe a formatter would be more appropriate?



    Add comment
    10|10000 characters needed characters exceeded

  • Sep 19, 2018 at 06:09 AM

    Hi Rio, is there a special reason for doing the aggregation on the JS side?

    As Jamie pointed out you should maybe use a formatter. SAPUI5 as most of the Web Frameworks follows the MVC (Model View Controller) pattern. Controllers should only handle the logic of your apps and Views (XML) should handle the presentation/rendering part. What you're trying to do should be handled by the view.

    If you do that bindAggregation in the XML and you use a formatter, the update of the value inside your firstStatus would be done automatically by UI5.

    If you post your XML view (or at least the binding part) I will be able to help you ;)

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 18, 2018 at 05:42 PM

    why not just manipulate the model/data?

    usually you can consider it is "illegal" to access the ui control in your code.

    Add comment
    10|10000 characters needed characters exceeded