Combobox Extjs 4在表单加载事件中设置combox值

Combobox Extjs 4在表单加载事件中设置combox值,combobox,extjs4,store,Combobox,Extjs4,Store,我有一个表单,其中包含两个combox字段,它们是链接的combox字段 章节和教训 当用户选择章节时,将显示该章节中的课程列表 如何根据ExtJS4中的章节组合过滤课程组合。若章节组合被选中,那个么只有课程组合应该显示课程,否则它应该是空的 以及如何设置从服务器加载表单数据并填充到表单字段时选择的cmobo值 章节商店 var chapter_store = Ext.create('Ext.data.Store', { autoLoad: true, fields: ['cha

我有一个表单,其中包含两个combox字段,它们是链接的combox字段

章节和教训

当用户选择章节时,将显示该章节中的课程列表

如何根据ExtJS4中的章节组合过滤课程组合。若章节组合被选中,那个么只有课程组合应该显示课程,否则它应该是空的

以及如何设置从服务器加载表单数据并填充到表单字段时选择的cmobo值

章节商店

var chapter_store = Ext.create('Ext.data.Store', {
    autoLoad: true,
    fields: ['chapter_id', 'chapter_name'],
    proxy: {
        type: 'ajax',
        url: BASE_URL + 'courses/chapters/getChaptersCombo/' + course_id,
        actionMethods: {
            read: 'POST'
        },
        noCache: false,
        reader: {
            type: 'json',
            root: 'results',
            totalProperty: 'total'
        }
    },
    storeId: 'chapter_id'
});
课程商店

var lesson_store = Ext.create('Ext.data.Store', {
    autoLoad: true,
    fields: ['lesson_id',
             //'chapter_name',
             'lesson_name', 'lc_relation_id'
             ],
    proxy: {
        type: 'ajax',
        url: BASE_URL + 'courses/lessons/getLessonsCombo/' + course_id,
        actionMethods: {
            read: 'POST'
        },
        noCache: false,
        reader: {
            type: 'json',
            root: 'results',
            totalProperty: 'total'
        }
    },
    storeId: 'lesson_id'
});
带有链接组合的表单

 var quiz_form = Ext.create('Ext.form.Panel', {
    items: [{
        xtype: 'combobox',
        //readOnly:true,
        id: 'test_chapter_combo',
        name: 'test_chapter_combo',
        //hiddenName: 'test_linkchapter_val',
        displayField: 'chapter_name',
        valueField: 'chapter_id',
        fieldLabel: 'Select Chapter',
        allowBlank: false,
        blankText: 'Chapter is required',
        triggerAction: 'all',
        queryMode: 'remote',
        store: chapter_store,
        selectOnFocus: true,
        listeners: {
            select: {
                fn: function (combo, value) {
                    var comboLesson = Ext.getCmp('test_lesson_combo');
                    comboLesson.clearValue();
                    lesson_store.load({
                        params: {
                            chapters_id: combo.getValue()
                        }
                    });
                }
            }
        }
    }, {
        xtype: 'combobox',
        //readOnly:true,
        id: 'test_lesson_combo',
        name: 'test_lesson_combo',
        //hiddenName: 'test_linklesson_val',
        displayField: 'lesson_name',
        valueField: 'lc_relation_id',
        mode: 'local',
        fieldLabel: 'Link To Lesson',
        allowBlank: false,
        blankText: 'Lesson is required',
        triggerAction: 'all',
        store: edu_lesson_store,
        queryMode: 'remote'
    }]
});
从服务器加载表单数据

quiz_form.getForm().load({
    url: BASE_URL + 'courses/getCourseTest/' + quiz_id,
    method: 'POST'
});

我不知道您使用的是哪种服务器端技术,但我相信您可以通过以下两个伟大的链接获得一些灵感/指导:


我使用PHP-codeigniter作为服务器端技术。现在过滤工作正常。当我从服务器加载表单数据(如已保存表单的编辑模式)并使用远程存储时,如何在combobox中设置值。如果对combox使用数组数据存储,则从服务器加载表单数据时会自动将值选择到combox中。尝试将combo配置中的name属性设置为“chapter\u id”,然后使用Try to use form。loadRecord(model\u record),form会将模型记录中的值绑定到具有name=“model\u field\u name”的表单字段,有关loadRecord()的详细信息,请单击此处