cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 List Bind Aggregation get Value of the list

0 Kudos

Dear SAPUI5 Gurus,

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

<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?

this.oListItem.getFirstStatus().getText()

Accepted Solutions (1)

Accepted Solutions (1)

jamie_cawley
Advisor
Advisor

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

this.oListItem.getItems()[0].getFirstStatus().getText();

Maybe a formatter would be more appropriate?

Regards,

Jamie

0 Kudos

this.byId("list").getItems()[0].getFirstStatus().getText()

Answers (2)

Answers (2)

ericci
Active Contributor

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 😉

junwu
Active Contributor

why not just manipulate the model/data?

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