Skip to Content
0
Sep 03, 2020 at 09:07 PM

sap.m.ComboBox unable to use comparator function

82 Views

I'm unable to run a comparator function on a sap.m.ComboBox to do a case-insensitive sort. Is there a workaround here? Control looks like below.

If I do "control.getBinding("items").sort(new sap.ui.model.Sorter("name", true, true, comparingFn)" it doesnt run.

const sorterTest = new sap.ui.model.Sorter("name");
sortStrings = (a, b) => {
	console.log({a, b})
	a = a.toLowerCase();
	b = b.toLowerCase();


	if (a > b) {
		return 1;
	} else if (a < b) {
		return -1;
	} else if (a === b) {
		return 0;
	}
};
sorterTest.fnCompare = sortStrings;


const control = new sap.m.ComboBox(sId, {
		items: {
			path: "/path",
			templateShareable: false,
			template: new sap.m.,
			sorter: [sorterText],
		},
});