0
votes

I have extjs form & php in back end ,in which i have created combo box,

I am able to set value in the combo box, but when i submit the form i am getting the displayfield in post data, and if i manually change the value of combo box i.e from 'two' to 'one' then the valuefield of combo is available in post data, Even the setRawValue gives same result. Here is my code :

var exampleData = [[1,'one'],[2,'two'],[3,'three']];

   var cmbJProject = new Ext.form.ComboBox({
        width          : 120,
        hiddenName     : 'project',
        store          : new Ext.data.ArrayStore({
                         fields : ['value', 'name'],
                         data   : exampleData 
                        }),
        valueField     : 'value',
        displayField   : 'name',
        typeAhead      : false,
        mode           : 'local',
        forceSelection : true,
        triggerAction  : 'all',
        selectOnFocus  : true,
        id             : 'project1',
        editable       : false
    });


    cmbJProject.setValue('two');
1

1 Answers

1
votes

Quoting Ext.form.ComboBox#setValue:

Sets the specified value into the field. If the value finds a match, the corresponding record text will be displayed in the field. If the value does not match the data value of an existing item, and the valueNotFoundText config option is defined, it will be displayed as the default field text. Otherwise the field will be blank (although the value will still be set).

It appears that it's behaving as described. Try:

cmbJProject.setValue(2);