I'm using Extjs4. I've to set combobox display field and value field in form load. setValue() not working for comboxes in form load. I'm using bellow code Please let me know whats wrong with my code.
quiz_edit_form.load({
url: BASE_URL + 'courses/testing/getCourseTest/' + quiz_id,
method: 'POST',
success: function(form, action){
var chap_name = action.result.data.test_chapter_combo;
var less_name = action.result.data.test_lesson_combo;
Ext.getCmp('test_chapter_combo1').setValue(chap_name);
Ext.getCmp('test_lesson_combo1').setValue(less_name);
}
});
Thanks
The value you are trying to set must be present in the store bound to your combo. To get your values in the store you must have it autoloaded or load it way ahead of time - remember the store loads asynchronously.
I've recently had a similar issue with the combos. Ensure the
forceselection
attribute on the combo's are set tofalse
, or it won't allow you to set any values that aren't in the store - and the store won't be loaded until a user clicks the trigger. If you do need to have the users only select options from the combo, setforceselection: false
, thensetValue
andsetRawValue
, thenforceselection: true
.Hope that helps.