Default value for ExtJs Combo box without using emptyText - combobox

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)

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

Sencha Touch how to set selected item in selectfield

I'm using Sencha Touch 2.3.1.
How to set an select item in a selectfield ? It's seem no method to support this. I don't want do the trick set an Placeholder to the selectfield.
I have tried to Google it. But it's seem nobody talk about this.
Obviously it supports.
The value of the Ext.field.Select itself is the value of the selected item. So, you can either set the initial value or dynamically change it at anytime with the value config, via setValue method.

Angular-xeditable - Editable Row - Change Value

I try to set a value of a select control to null when a checkbox is unchecked.
I try with onbeforesave and onaftersave but i want to do it dynamicly , so i used e-ng-change. I want also to not change the value if i cancel my changes but i can't access to the control value.
You can see the code here : http://jsfiddle.net/NfPcH/2833/
In normal forms, i set the value like this but here i don't have any know access
sco.editableForm.name.$setViewValue("1234")
Regards,
Marc
I found a solution of my problem to set value in editable mode :
sco.rowform.$editables[2].scope.$data = null;

ExtJS 4 - How to avoid grid column value becoming null when column editor is combo-box?

I have a column in a grid with editor as combo-box.
When the grid is loaded then all the column values get displayed properly.
The issue is, when user clicks at the column (having combobox as editor) to edit it then the column value becomes null as shown in the attached screenshot.
I understand that the value becomes null as the store of combobox has not been loaded yet.
I can not use autoLoad true due to the heavy amount of data present in the combobox store. Moreover, even if I use autoLoad:true for the store with paging in it, then that too safeguards only those values which are present in the first page and not all.
Thus, how can I maintain the value in grid column when that value is not present in the store of combobox used as editor for the column?
Could anyone guide at this?
PS: I am using ExtJS Ver 4.0.2a
I have been able to find a solution for this.
It has more to do with the version of ExtJs. If we upgrade to 4.0.7 and then use forceSelection:false for a combobox then things work fine as expected. That is, the combo-box accepts a value which doesn't exist in its store and doesn't set the current value to null.
Hope this helps someone else too looking for something similar.
I would suggest having the grid record contain both that columns value, as well as display value. If the combo store lookup is unable to find a matching value (because that combo store hasn't been loaded yet), then revert to showing the display value stored with the grid record.
You might also need to have the afteredit event on the grid update that grid records display value after that column is edited for a particular row.

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

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

Resources