2012-02-17 2 views
0

2 콤보 상자 세트가 있습니다. 하나는 국가의 콤보이며 다른 하나는 국가의 콤보입니다. 기본적으로 국가를 선택하면 국가 콤보 저장소가 비어 있고 콤보 값 필드를 기반으로합니다. 국가 콤보는 첫 번째 콤보에 따라 필터링되거나로드되어야합니다. Extjs2.0에서는 Extjs4의 변경 내용이 작동합니다.Extjs4 연결 콤보

국가 저장소

var country_store = Ext.create('Ext.data.Store', { 
    //autoLoad: true, 
    fields: ['id','c_id','c_name'], 
    proxy: { 
     type: 'ajax', 
     url: 'country_list.php', 
     reader: { 
      type:'json', 
      root: 'results' 
     } 
    }, 
    storeId: 'edu_context_store' 
}); 

주 저장소

var state_name = Ext.create('Ext.data.Store', { 
autoLoad: true, 
fields: ['id','s_id','s_name','parent_country_id'], 
proxy: { 
    type: 'ajax', 
    url: 'states_list.php', 
    reader: { 
     type:'json', 
     root: 'results' 
    } 
}, 
storeId: 'state_name' 

});

콤보 상자

{ 
      xtype: 'combo', 
      id: 'country_combo', 
      hiddenName: 'country_name', 
      displayField: 'c_name', 
      valueField: 'c_id', 
      fieldLabel: 'Country', 
      queryMode: 'remote', 
      allowBlank: false, 
      triggerAction: 'all', 
      store: country_store, 
      width: 450, 
      selectOnFocus: true, 
      listeners:{ 
      scope: this, 
      'select': function(combo, rec, idx){ 
       var country_val = combo.getRawValue(); 
       var states_obj = Ext.getCmp('states_combo');   
         states_obj.clearValue(); 
         //states_obj.store.load(); 
         states_obj.store.filter('parent_country_id', country_val); 


      }       
     } 

     }, { 
      xtype: 'combo', 
      id: 'states_combo', 
      hiddenName:'state_name', 
      displayField:'s_name', 
      valueField:'s_id', 
      queryMode: 'remote', 
      fieldLabel: 'State', 
      cls: 'textlineht', 
      allowBlank: false, 
      triggerAction: 'all', 
      store: states_store, 
      width: 450 

     } 

사람은 그렇게하는 방법을 알고?

감사합니다.

+0

왜 댓글을 달았습니까? //states_obj.store.load(); – user1163459

+0

상태 저장소에 autoLoad : true 속성을 정의했습니다. – siva565

+0

^렌더링 될 때 한 번로드되므로 더 이상 – Mchl

답변

1

combo.getRawValue()은 기본 id 값이 아닌 콤보에서 사용자에게 표시되는 값을 반환합니다. 대신 combo.getValue()을 입력하십시오.

+0

감사합니다 Amalea.By combo.getValue()를 사용합니다. valueField를 얻을 수 있지만 상태 조합은 필터링되지 않습니다. – siva565

+0

카운티와 주 (json) 데이터를 얻습니다. 이처럼 // Country Store ({ "total": "2", "results": [{ "id": "1", "c_id": "US", " {{ "total": "c_name": "c_name": "미국",}}} // 미국 스토어 ({ "total": " 2 ","결과 ": [{" "id": "7", "s_id": "nyk", "s_name": "뉴욕", "parent_country_id": "US"}, { "id": "8 ","s_id ":"lon ","s_name ":"Landon ","parent_country_id ":"UK "}]}) – siva565

+0

문서에서 청취자는 다음과 같이 설정되어야합니다.'listeners : {select : {fn : function() {}, scope : this}}',이 문법으로 다시 작성해보고 도움이되는지 확인해 보겠습니다. – Amalea