问题
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
回答1:
I've recently had a similar issue with the combos. Ensure the forceselection
attribute on the combo's are set to false
, 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, set forceselection: false
, then setValue
and setRawValue
, then forceselection: true
.
Hope that helps.
回答2:
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.
来源:https://stackoverflow.com/questions/9327629/extjs4-combobox-set-value-field-and-display-fileld