3

In combo editor, after select a option, it display value even I set display Field. Once I click the combo editor, it will display displayField as well, but after select and click the others (It means mouse out) then the cell value changed to valueField.

my combo editor code,

{
   xtype : 'combo',
   editable : false,
   triggerAction : 'all',
   displayField : 'name',
   valueField : 'id',
   store : myStore
}

what I missed?

anyone know, please advice me~

Thanks!

[Edit]

I write test code in here :

http://jsfiddle.net/ilovekanon/NQXw9/

change name and click the others then the name will show ID, not name :(

Expert wanna be
  • 10,218
  • 26
  • 105
  • 158

2 Answers2

2

You need to add a model (or a model config) to the combo's store, then call .setValue()

combo.store.add({id:3, name:'expert wanna-be'});
combo.setValue(3);

Example:

http://jsfiddle.net/y944g/

The model will be over-written when you load the combo's store (by clicking the trigger), so you don't have to worry about duplicates or anything.

Mechanical snail
  • 29,755
  • 14
  • 88
  • 113
Neil McGuigan
  • 46,580
  • 12
  • 123
  • 152
  • this example does not uses a cell editing plugin - the question specifically asks for an issue in the combo editor (facepalm) – code4jhon Apr 15 '15 at 04:57
  • @code4jhon what are you talking about? There is no mention of "cell editing plugin" in the question or my answer. – Neil McGuigan Apr 15 '15 at 19:10
  • the question say combo editor that means there is a cell or row editing plugin - this is a real issue using those plugin your example works because non of these are being used – code4jhon Apr 15 '15 at 19:20
1

Your jsFiddle code dose not wrong.

displayField in combo is mean that displayed data field name in combo. It's not displayed value in grid. grid display selected value, when selected option in combo. if you want to display name in combo's store, valueField must is set 'name',

So, If you need to id in combo's store, You maybe set new hidden grid column. when change event trigger.

zziuni
  • 36
  • 2
  • Aha! thank you! do you know where I can find a example for hidden grid column for editor combobox? hhhhhh ^^* – Expert wanna be Jul 31 '12 at 11:17
  • First, Set a column. `{ header: 'id', hidden: true }` – zziuni Jul 31 '12 at 23:25
  • And then add `change` listener on the combo. This listener argument is selected value. write code that set the value for select row. [reference](http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.ComboBox-event-change) , [other](http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.Panel-method-getSelectionModel) – zziuni Jul 31 '12 at 23:35
  • Dear @zziuni... Is it neccessary to add an id field in model for the hidden column to send it back when we make an update? or just we must manage it in the row? Thank you for your time... – sonseiya Jun 12 '13 at 16:54