2012-11-06 2 views
1

가능한 중복 :
Cascading Combobox in extjs동적으로 데이터를로드

안녕하세요 즉, 두 개의 콤보가 ..

AcademicClass

{ 
    xtype : 'combobox', 
    emptyText : 'Academic Class', 
    displayField : 'name', 
    id:'comboacademicclass', 
    valueField : 'id', 
    store:classstore, 
    triggerAction:'all', 
    mode:'local', 
    listeners : { 
     'select' : { 
      fn: function(combo1, value) { 
       var comboSubject=Ext.getCmp('combo-subject'); 
       var classId=Ext.getCmp('comboacademicclass').getValue(); 
       comboSubject.setDisabled(true); 
       comboSubject.setValue(''); 
       comboSubject.getStore().removeAll(true); 
       comboSubject.getStore().load({url:'http://localhost:8080/WebService/rest/type/academicSubjectByClass/'+classId+'.json'}); 
        // Using this loading data in second combobox by passing first combobox Id.:- 'classId'. 
        comboSubject.setDisabled(false); 
      } 
     } 
    } 
} 

AcademicSubject는 : 단지 처음 선택하지만, 제 시간에 선택

{ 
    xtype : 'combobox', 
    emptyText : 'Academic Subject', 
    id:'combo-subject', 
    displayField : 'name', 
    valueField : 'id', 
    disabled:true, 
    store:subjectstore, 
    triggerAction:'all', 
    mode:'local' 
    ,lastQuery:'' 
} 

그 표시 출력은 단지 "로드"를 나타내는 출력을 dispalying 없다. 도와주세요.

+0

버전을 알려주십시오. 2.x, 3.x 또는 4.x – sra

답변

1

select 또는 change 이벤트의 AcademicClass에서 AcademicSubject 콤보를 듣고 함께 듣기 콤보를 활성화해야합니다. 또한 선택한 값을 가져 오므로 활성화 콤보에 대한 쿼리를 준비 할 수 있습니다. 당신은 combobox가 AcademicClass 콤보에서 활성화 된 콤보 (AcademicSubject)와 value는 PropertyValue에 대한 참조입니다

combobox.queryData = [{ property: 'fieldName', value: value}]; 
combobox.reset(); 
combobox.doQuery(combobox.queryData); 

같이이 작업을 수행 할 수 있습니다. 을 미리 들어 나는 새로운 PARAM을 도입 할 필요없이 기본 서버 측 필터 동작을 사용할 수 있도록 할 queryParam: 'filter'를 사용하는 것이 좋습니다 위 :주의

combobox.on('beforequery', function (e) { 
    e.query = e.combo.queryData; 
}); 

사용하여 새 쿼리의 사용을 보장합니다.

관련 문제