Showing results for 
Search instead for 
Did you mean: 

sap.m.ComboBox unable to use comparator function

0 Kudos

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],

Accepted Solutions (0)

Answers (1)

Answers (1)

Active Contributor
0 Kudos

Is it because of a Typo: sorterText -> sorterTest ?

0 Kudos

sorry, that was just a typo in the question. I can sort descending/ascending no problem (meaning the sorter is working), but doesn't take the comparator function.