在extjs中级联组合框

时间:2012-11-02 10:23:59

标签: javascript spring hibernate extjs

我想在extjs中进行级联组合框。我必须组合框

课程组合框

{ 
    xtype : 'combobox',  
    emptyText : 'Course',  
    id:'combo-course',  
    displayField : 'name',  
    valueField : 'id',  
    store:coursestore,  
    forceSelection: true,  
    triggerAction:'all',  
    queryMode: 'remote',  
    listeners: {  
        'select': {  
            fn:function(combo, value) {  
                var comboModule = Ext.getCmp('combo-module');  
                comboModule .setDisabled(true);
        comboModule .clearValue('');
        comboModule .getStore().removeAll();
        comboModule .getStore().load({
        params: {courseId: combo.getValue()}
         });
                comboModule .setDisabled(false);  
            }  
        }  
    }  
}

课程-模块:

{
    xtype : 'combobox',  
    emptyText : 'Module',  
    id:'combo-module',  
    displayField : 'name',  
    valueField : 'id',  
    disabled:true,  
    remoteFilter:true,  
    store:coursemodulestore,  
    forceSelection: true,  
    queryMode: 'remote',  
    triggerAction:'all'
}

休息服务

    @Path("/coursemodule/{courseId}")
    public List<CourseModule> getAllCourseModules(@PathParam("courseId")String courseId ) {
        try {           
            return courseObj.getModulesForCourse(courseId);
                } catch (HibernateException e) {
            logger.debug(e.getMessage());
        }
        return null;
    }

当我运行应用程序并选择第一个组合框时,它仅在第一次在第二个组合框中显示正确的值;
但是当我第二次选择组合框时它没有在第二个组合框中显示值。

3 个答案:

答案 0 :(得分:1)

您似乎想要清除已应用的过滤器。要删除已应用的过滤器,商店上会提供clearFilter()方法。您可以将其混合到您的代码中,类似于:

comboModule.clearValue();  
// new line to clear any filter applied to the store
comboModule.getStore().clearFilter(true);  
comboModule.getStore().filter('courseId',combo.getValue());  

答案 1 :(得分:0)

很可能你的问题是store.load()是异步的。 尝试在load的回调中传递剩余的逻辑(过滤等)。

答案 2 :(得分:0)

第二次加载时是否显示LoadMask?

使用此选项覆盖该行为:

Ext.override(Ext.LoadMask, {
    onHide: function() {
    this.callParent();
  }
});