Sencha recommends to avoid manual loading of data into a form and use loadRecord
instead. But if there are combos in the form, what happens is that valueField
is inserted into the text area, instead of displayField
. One would think that the associated store should be loaded first and then the loadRecord
has to be invoked. But what is the proper way?
Asked
Active
Viewed 94 times
1

jayarjo
- 16,124
- 24
- 94
- 138
2 Answers
1
loadRecord
is a very simple function that takes values from the record fields and then calls setValue(recordFieldValue)
on the corresponding form fields (where name of the record field matches name of the form field).
Hence, if the form field combo store is not loaded, or if recordFieldValue
is not found in the store, then the raw value is just displayed in the text part of the combo.
You must assure that the combo store is loaded before you call load record.

Saki
- 5,827
- 2
- 15
- 15
-
That's exactly what I do, but it seems to be a bit too primitive. I haven't tried but maybe if the record contains both - valueField and displayField then loadRecord will display it properly? – jayarjo Oct 30 '14 at 17:37
-
It's all about calling `combo.setValue(recordFieldValue)`. Combo has store with value/text pairs so if `recordFieldValue` does not match any record in the store then value, not text, is displayed in the combo. – Saki Oct 31 '14 at 09:49
-
I ended up writing my own variation. – jayarjo Dec 10 '16 at 05:17
0
you need to add the key "name" to each form field to have it working. Then you can add either a record to be loaded or to add data.
intialize: function() {
var data = {
nameOfComboItem: false, // validValue
nameOfSecondComboItem: true
};
this.down('formpanel').setData(data);
}

Dinkheller
- 4,631
- 5
- 39
- 67
-
-
I've reread my question and apparently it was a bit ambiguous. So I clarified it a bit. – jayarjo Oct 26 '14 at 17:37