Why does readonly mode stop the filtering mode with the dhtm

When I enable readonly the filtering no longer works.

In the script below if I am not using readonly filtering works, so I can enter 11 as an example and see the first two options. Then when I add the readonly and enter 11 only the first option comes up, I can no longer see the 2nd option even though it starts with 11.


this is correct behaviour as read-only mode doesn’t disable combo input for typing.

You can try to use the following approach instead of readonly() - in this case a user will be allowed to enter only values that are presented in list:

var val=’’;

else val = z.getActualValue()

This allows anything to be typed in but removes it after they exit the combo box which would confuse the user as they would wonder why what they typed just disappeared.  As you mention above, I need to allow the user to enter only values that are in the list, if they start typing something that is outside the list it needs to not allow that.

There is “onKeyPressed” event handler you can use your approach that will check options in combo:

var text = “”;

if(checkText(this.getComboText())) text=this.getComboText();
else this.setComboValue(text);

What is the function checkText in your code? It is not a standard JS method, nor is it contained anywhere within the dhtmlxcommon.js or the dhtmlxcombo.js code.

I’m looking to only allow someone to enter text in the combo box that would match an existing option.

For example, if I have options:

I want someone to be able to enter “abc” but not “abd”.



What is the function checkText in your code?

You need to implement this function. It should validate whether text is in the option - you need to organize loop through all options that you load into the combo.

That’s precisely what I was afraid of. I basically have to replicate the logic from the filterSelf method of the combo. Which is very inefficient. I have to create a new RegEx, and test against all the options - exactly what the filterSelf function is doing.

The other option is to somehow modify your actual Combo code, which seems a little tricky to accomplish as well. I am very surprised that this is not a feature that you would already have built into the Combobox.