Skip to Content

[UI5] Is there group function in the items of a sap.m.Select?

Hi experts, I have Select countrol for product. And bind a list of products to the items property. I want to have the feature that, when user open the select dropdown list all products are grouped into two categories (available and unavailable), and sorted by the name. So I have the folloing code:

this.byId('productSelect').getBindingInfo('items').sorter = new sap.ui.model.Sorter("", null, function(oContext) {
	            return oContext.getProperty("available") ? 
	                {key: 'available', text: 'Available'} :
	                {key: 'unavailable', text: 'Unavailable'}
			}, function(a, b) {
                if (!a.available && b.available) {
                    return 1;
                } else if (a.available && !b.available) {
                    return -1;
                }
                return a.productName.toLowerCase().localeCompare(b.productName.toLowerCase());
            });

The sorting function worked and the products are sorted like I expected. But there's no group headers like sap.m.List in DemoKit. So I want to know does items in sap.m.Select support grouping? Thank you so much!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Dec 09, 2017 at 03:52 AM

    Hi Cong Wang,

    According to standard FIORI Guidelines, you should not use grouping within your sap.m.select. But, you can use custom filters and grouping in your case.

    Regards,

    Arjun Biswas

    Add comment
    10|10000 characters needed characters exceeded