on 09-18-2018 6:08 PM
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()
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 😉
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
why not just manipulate the model/data?
usually you can consider it is "illegal" to access the ui control in your code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.