cancel
Showing results for 
Search instead for 
Did you mean: 

ComboBox prevent user from typing

0 Kudos

Hi,

I would like to know if it is possible to prevent the user to type in a ComboBox?

The user can only select one of the options. I want the same behavior as the sap.m.Select, where the user cannot type or "select empty".

Thanks, Cristiano.

Accepted Solutions (1)

Accepted Solutions (1)

former_member183518
Active Participant

You can fetch the jQuery instance of the input control used in the ComboBox and set the attribute readonly to true.


oComboBox.addEventDelegate({

         onAfterRendering: function() {

              oComboBox.$().find("input").attr("readonly", true);

         }

});

updated jsbin link - JS Bin - Collaborative JavaScript Debugging

Answers (2)

Answers (2)

kedarT
Active Contributor
0 Kudos

Hi,

Taking cue from - here is the example - JS Bin - Collaborative JavaScript Debugging

Sakthivel you link for jsbin does not have any code.

former_member183518
Active Participant
0 Kudos

Thanks for pointing out. Updated the link.

Former Member
0 Kudos

Hi,

In compobox change these lines, oComboBox1.setEditable(true); to oComboBox1.setEditable(false);

0 Kudos

Hi Pradeep,

No, the editable to false make it read only, it is not what I want.

I still want to allow the user to select one of the options.


thanks.

Former Member
0 Kudos

Hi,

oDropdownBox.getLiveValue(); i think it works

Ref: Get the selected item from DropdownBox | SCN

0 Kudos

Hi, and how with this method I would prevent the user from typing?

Former Member
0 Kudos

Hi,

In compobox change these lines, oComboBox1.setEditable(true); to oComboBox1.setEditable(false); this will prevent user to type

and

oDropdownBox.getLiveValue(); i think it works to select item

Ref: Get the selected item from DropdownBox | SCN

0 Kudos

hi,

regarding the editable, go to :http://veui5infra.dhcp.wdf.sap.corp:8080/snippix/#39411 test and uncomment the editable line, and check. This is not what I want. thanks.

Former Member
0 Kudos

Hi,

Can you send code in jsbin r jsfiddle, i cant open the link shows The server at veui5infra.dhcp.wdf.sap.corp can't be found because the DNS look-up failed. DNS is the network service that translates a website's name to its Internet address.

Former Member
0 Kudos

Hi,

this is sample code JS Bin

But i could not make make that editable, i think in dropdown we can't prevent user from typing. Returned the value on click