6

I made a combobox using sap.m library:

var oSelection = new sap.m.ComboBox({
    name:   <name>,
    id:     <id>,
    items: {
        <items here>
        })
    },
});

Now, how do I make this field kind of read only, so when I tap it on mobile, it wouldn't bring up the mobile's keyboard, but it would bring up the selection options? I've tried to use editable: false, but it disables the selection together with keyboard.

Thank you.

keshet
  • 1,716
  • 5
  • 27
  • 54

2 Answers2

1

From what I could find out there's no method that allows such behaviour.

One option, that I personally would not advice, is to access the HTML DOM and disable the input field that composes the sap.m.Combobox component.

Keep in mind that if the development SAPUI5 changes the inner workings of the Combobox component your code could be broken if you update the SAPUI5 libraries.

This being said, to use this option you could do something like:

        oSelection.onAfterRendering = function() {
            if (sap.m.ComboBox.prototype.onAfterRendering) {
              sap.m.ComboBox.prototype.onAfterRendering.apply(this);
            }
            document.getElementById("<id>-inner").disabled=true;
        }

replace the < id>-inner by the correct id given to your component.

This was tested using version 1.22.8 of SAPUI5 development toolkit.

mjd
  • 406
  • 1
  • 3
  • 7
  • 1
    Looks loki I'll have to use Select eventually. Your solution is OK, but I really don't want to mess with the application every time the SAP libraries are updated. Thaks anyway. – keshet Oct 05 '14 at 05:53
0

Use sap.m.Select instead of sap.m.ComboBox.
Select does not provide the ability to edit the field content.

In many instances the Select control can directly replace a ComboBox without any other changes to the properties or the items aggregation!

Jpsy
  • 20,077
  • 7
  • 118
  • 115