SAPUI5 List Bind Aggregation get Value of the list

Viewed 539

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

Controller

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()

Update - View

<List id="list" growing="true" growingThreshold="20" growingScrollToLoad="true" showNoData="true" mode="{device>/listMode}"
                select="_handleSelect">
                <ObjectListItem id="MAIN_LIST_ITEM" type="{device>/listItemType}" press="_handleItemPress" title="{sName}">
                    <markers>
                        <ObjectMarker type="Flagged"/>
                    </markers>
                    <firstStatus>
                        <ObjectStatus text="{Status1Txt}"/>
                    </firstStatus>
                    <attributes>
                        <ObjectAttribute id="ATTR1" text="{SNumber}"/>
                        <ObjectAttribute id="ATTR2" text="{PTxt}"/>
                    </attributes>
                    <secondStatus>
                        <ObjectStatus text="{Status2Txt}"/>
                    </secondStatus>
                </ObjectListItem>
            </List>
1 Answers

So if I understand correctly, you're trying to retrieve the status text of an entry, but what you're actually doing is retrieving the default template of the ObjectListItem.

If you want the correct value for an entry, you can try this. This returns a filled clone of the default template. You can't clone() an empty template and expect it to have values in it.

Hope this helps, lampstand.

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