keshet
keshet

Reputation: 1826

Why grouping creates 2 different groups for same field value?

I use OData direct binding to XML view:

<List items="{path:'Items', sorter : {path : 'group', group : true}}">
...
</List>

The 'Items' content, bottom line, looks like follows:

[{
    group: "1",
    value: "a"
},{
    group: "1",
    value: "b"
},{
    group: "2",
    value: "c"
},{
    group: "2",
    value: "d"
},{
    group: "1",
    value: "e"
}]

Strangely, I see 3 groups in my list: group "1" with 2 elements, group "2" with 2 elements and again group "1" with one last element.

What do I miss?

Thank you.

Upvotes: 0

Views: 164

Answers (1)

Inizio
Inizio

Reputation: 2256

It is a duplication of the SAPUI5 - Group list items without sorting ascending or descending

You have missed groupHeaderFactory, I have made the changes as per the requirement.

View

<List headerText="Products"          
    items="{
        path: '/items',
        sorter: {
            path: 'group',
            descending: false,
            group: true
        },
        groupHeaderFactory: '.getGroupHeader'
    }">

Controller

getGroupHeader: function (oGroup){
    return new sap.m.GroupHeaderListItem({
        title: oGroup.key,
        upperCase: false
    });
},

Upvotes: 1

Related Questions