How to make Ext.form.Combobox cannot input "dirty" data - extjs

Do we have any way to make an Ext.form.Combobox cannot input the data which is not in combobox's store?
It means that user can type to field for filter items quickly, but they cannot input the "dirty" data outside of the combobox's store? Does ExtJS support this feature by configuring properties or we have to customize it?!
Thank you very much!

Configuring your combobox with the editable:false and forceSelection:true should suffice

combo has 2 variables (like <select>) value and display. Even you set editable:true what is default and allow you to write in combo, whatever you write it should mach display in order to set value...
In you case wiget of TextField with autosuggest (not need to AJAX) would work

Related

Codename One ComboBox how to highlighting already selected value

We are able to create ComboBox and populating data too. But we need to highlighting already saved values. Can you please suggest code for this.
Our requirement is if Combobox has 1,2,3. If I select 2 and save. We need to set the combo box value 2 in such way that when we open the Combobox need to display this 2 as highlight value along with 1,2,3 values.
Simply same as select box option selection.
I would generally recommend avoiding ComboBox altogether.
Assuming this isn't an option you will need to define a renderer and disable the OS specific 2 render mode using a theme constant:
otherPopupRendererBool=false

Reset a ComboBox

I have a view that contains several ComboBox elements. For some reason old data remains from the previous time the view was opened and I would like to reset the combobox elements in the view every time it is opened. Is there a function that could that for me? I want it to be exactly how it is as if I rendered it the first time with the initial items. Would using setSelectedItem(vItem), setSelectedItemId(vItem), setSelectedKey(sKey), setShowSecondaryValues() help? If so, what do these keywords mean (selectedItem, selectedItemID, selectedKey, secondaryValues)?
Unfortunately you do not provide an example. Normally you bind your UI controls against a model, e.g. JSONModel. In this case the items of your ComboBox controls would be taken from the corresponding model. However, you can use method removeAllItems to achieve the desired behaviour.
UPDATE: Obviously the controls are bound and only the selection should be cleared.
Use setSelectedItem with value null to clear the selection. You could also use the binding to set the selected item automatically by using the selectedKey attribute, see example.

Vaadin: Reload ComboBox List while typing

I got a ComboBox in Vaadin and want to reload (from db) the set of entries in the dropdown list while typing in the text field of the ComboBox. I always got the exception:
java.lang.IllegalStateException: A connector should not be marked as dirty while a response is being written.
I tried to lock the session (getUI().getSession().getLockInstance().lock();), but it didn't help.
Is it possible to dynamically set/load the selection list of a ComboBox?
Cheers
Stefan
why do you want to change the content from DB as the user type? you'll get a postback and a query every key the user presses... isn't better to use the standard combo feature (which tries to autocomplete the value given what the user is typing)?
Anyway, if you really need this feature, you may extend the standard behaviour of combo extending the container behind the combo, as the data shown is taken from a container.

Default value for ExtJs Combo box without using emptyText

I'm using ExtJs 4 and in my Web application I have a combo box. Previously I used to set the default value of the combo box using emptyText. It works just fine. But, is there any alternative way of setting the default value for the same?
I looked into different questions here on SO and tried the following -
Ext.getCmp('myComboBoxID').setValue("myValue");
However, this doesn't seem to be working. I also tried the simple value attribute to no avail. How can I the set the default value other than using emptyText?
Also, when the value is set using emptyText, it is displayed in gray color (which is poorly vsible), I was wondering if one can work with the opacity of the ExtJs select box?
Update: I used Ext.getCmp('myComboBoxID').setRawValue("myValue"); to set the value & it worked. What is the difference between setValue() & setRawValue()?
You need to supply the id to getCmp method. Try the following.
Ext.getCmp('#myComboBoxID').setValue("myValue");
I used Ext.getCmp('myComboBoxID').setRawValue("myValue"); to set the value & it worked.
The store needs to be loaded before you call setValue and you use the id of the record you want to select. There is a load event you can listen for if the values are loaded from the server. emptyText is not intended for default values, but to help the user understand what should be done with the field (eg "Select a state" from a list of states)

How to filter a combobox dropdown list without filtering the store? is it possible?

I have two ComboBoxe's that use the same store. I want to filter the second combo with the select triggerAction on the first. If i filter the store of course it will be filtered for the first combo as well, and i don't want that so .. Is it possible to filter the dropdown list of an combobox without filtering the store? Thanks. If you can provide an example it would be great.
You can link the combo boxes this way... A selection in the first combobox is used as a parameter for the request in the second... once the parameter's value is set for the 2nd combobox's store, you can make an ajax call to your service to return the "filtered" data.
You'll need to use the store.reload() function to pull this off.

Resources