I am very new to SAPUI5. I have a scenario thus:
A master-detail page (from the master-detail template available via SAP Web IDE, views are XML) displays items from my model(mockdata).
The master section is bound to entity Interests
. The detail section gets its information from entity Messages
. I have referential constraints between them and it works perfectly alright. Tapping on items in my master section displays the corresponding items in the table in the details section.
The master section list:
<List
id="list"
items="{
path: '/InterestsSet',
sorter: {
path: 'InterestShortDescription',
descending: false
},
groupHeaderFactory: '.createGroupHeader'
}"
busyIndicatorDelay="{masterView>/delay}"
noDataText="{masterView>/noDataText}"
mode="{= ${device>/system/phone} ? 'None' : 'SingleSelectMaster'}"
growing="true"
growingScrollToLoad="true"
updateFinished="onUpdateFinished"
selectionChange="onSelectionChange">
<items>
<ObjectListItem
type="{= ${device>/system/phone} ? 'Active' : 'Inactive'}"
press="onSelectionChange"
title="{InterestShortDescription}"
number="{path :'MessagesSet', formatter:'.productCount'}">
</ObjectListItem>
</items>
</List>
The Master section needs to display a number value that equals the total number of items that is displayed in Entity Messages
(i.e. equal to the number of rows displayed in the details section). After some research (ultimately from SAPUI5 - How to Bind Odata $count to a XML view)i came to know about the formatter
property and added it.
My formatter reads thus:
productCount: function(oValue){
if (oValue) {
var sPath = this.getBindingContext().getPath() + '/MessagesID';
var oBindings = this.getModel().bindList(sPath);
return oBindings.getLength();
}
}
I tried logging oValue
, but it seems to be returning as undefined
.
Is there anyway to get the count for each item in the master list.