2013-03-13 35 views
1

我想填充第二個組合,具體取決於json響應中的第一個組合,如在第一個組合中使用類別值顯示第二個組合中的子類別值。我的所有值都來自json數組響應,我試圖動態設置root屬性,並在第一個組合框更改函數中加載控制器中的第二個組合框的存儲,但它沒有填充數據。有人可以告訴我問題是什麼。我如何解決它?我已經發布我下面的代碼,第一個組合的變化功能:如何填充第二個組合值取決於sencha中的json響應的第一個組合值

valueChange:function(combo, ewVal, oldVal,optionsVal) { 
    for(var i=0;i<tempstore.getCount();i++){ 
      var record = tempstore.getAt(i); 

//checking for user selection id with store id 
if(record.get('categoryId')==ewVal)   
{ 
    value="category.category1.category["+i+"].subCategory.subCategory1"; 
tempsecondCompostore.getProxy().getReader().setRootProperty(value);  
tempsecondCompostore.load(); 
cmbSecond.setStore(tempsecondCompostore); 

mdSecond.setDisplayField('subCategoryName'); 
cmdSecond.setValueField('subCategoryId'); 
break; 
     } 
     } 

這是我的第二個組合產品型號:

Ext.define('Test.model.SubCategoryModel', { 
    extend : 'Ext.data.Model', 
    fields : [ 
    { 
     name:'subCategoryName', 
     type:'string' 

    }, 
    { 
     name:'subCategoryId', 
     type:'string' 
    } 


    ] 

}); 

這是我的第二個組合店:

Ext.define('Test.store.SubCategoryStore', { 
    extend : 'Ext.data.Store', 
    storeId : 'secondcombo', 
    model : 'Test.model.SubCategoryModel', 
    //autoLoad : 'true', 
    proxy : { 
     type : 'ajax', 
     url : 'data.json', 
     reader : { 
      type : 'json', 
      rootProperty:'category.category1.category[0].subCategory.subCategory1 
     } 
    } 

} );

在視圖中顯示組合:

xtype: 'fieldset', 
      width:400, 
      heigth:200, 
      items: [ 
       { 
        xtype: 'selectfield', 
        label: 'Select', 
        store : 'secondcombo', 
        width:400, 
        heigth:200, 
        queryMode: 'local', 
        displayField :'subCategoryName', 
        valueField :'subCategoryId', 
        id:'cmbSecond' 




       } 
      ] 

感謝

回答

0

的問題是,這家店的()的負載是異步的,你需要包括此調用回調後的行。

相關問題