While using combos in an input form, I encountered an intriguing issue. The form has combos that retrieve data from JSON stores. Everything works smoothly when adding a new record, but when editing an existing one, the ID sometimes appears selected instead of its corresponding value (for example, '5' instead of "apple"). It seems like the value is being set before the combo finishes loading.
Is there a solution to this problem? Below is the code snippet that creates the combos:
function createDictionaryCombo(store, fieldLabel, hiddenName, name, allowBlank, myTooltip) {
combo = {
xtype: 'combo',
id: 'id-' + name,
allowBlank: allowBlank,
fieldLabel: fieldLabel,
forceSelection: true,
displayField: 'value',
valueField: 'id',
editable: false,
name: name,
hiddenName: hiddenName,
minChars: 2,
mode: 'remote',
triggerAction: 'all',
store: store
};
function createDictionaryJson(url) {
store = new Ext.data.JsonStore({
root: 'results',
fields: ['id', 'value'],
url: url,
autoLoad: true
});
return store;
}
var comboKarStore = createDictionaryJson('/service/karok');
var comboKar = createDictionaryCombo(comboKarStore, 'Kar', 'karid', 'kar', false, '');
// then comboKar is added to the form
Hubidubi