Reputation: 4098
I have a sap.m.List in openui5 which is bound to a JSON model.
The list should contain normal list items (such as the type sap.m.StandardListItem), but there should also be separator once every year through the list item type sap.m.GroupHeaderListItem. Example JSBin with such a list
Is it possible to achieve this when the data is bound using bindAggregation?
Upvotes: 0
Views: 820
Reputation: 4920
Yes, should be perfectly possible, have a look at the example at https://sapui5.hana.ondemand.com/sdk/explored.html#/sample/sap.m.sample.ListGrouping/code
Of course you need to sort your aggregation to the field you need to group on, and then you can supply a groupHeaderFactory
to your items aggregation:
<List items="{
path: '/ProductCollection',
sorter: {
path: 'SupplierName',
descending: false,
group: true
},
groupHeaderFactory: '.getGroupHeader'
}">
and the called factory function then returns a GroupHeaderListItem
based on a certain value for your data:
getGroupHeader: function (oGroup){
return new sap.m.GroupHeaderListItem( {
title: oGroup.key,
upperCase: false
});
}
Upvotes: 2