Extjs4 combobox set value field and display fileld

2019-07-24 18:43发布

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

2条回答
对你真心纯属浪费
2楼-- · 2019-07-24 19:35

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.

查看更多
聊天终结者
3楼-- · 2019-07-24 19:44

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.

查看更多
登录 后发表回答