PDA

View Full Version : Combobox and querymode = remote



miroperez
11 Jun 2012, 1:22 PM
If you are using the queryMode of 'remote' on a combobox component, how can I have the display text be displayed if I can an initial value which isn't loaded in the store yet? For example, the previous time the user selected a value in a form it was value='fooId', display='Foo' from the model. When I load the form again (say an edit), I pass in value='fooId' in the config and I want 'Foo' to show up in the input display field.

Can I do this with the existing API?

Thanks,
Miro

tobiu
12 Jun 2012, 12:46 AM
For just displaying a value in the input field, go for:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.ComboBox-method-setRawValue

However, when you submit the form this can cause errors depending on your validation rules (since the combo is not aware of the matching valueField id).

The probably cleaner way would be to use combo.getStore() and add your new value as a record there. then you can just select it.