今天用ext实现二级联动,原来以为很简单,但是试了半天,第二个下拉列表就是不能显示
后来发现后台向前台传json值用了对象,显示就出了问题,费了半天劲才搞出来,
certifcateTypeStore = new Ext.data.JsonStore({ url:'../getCertificateTypeListByArray', root:'certificateTypeList', fields:['certificateTypeId','certificateTypeName'] }); qytg_certificateTypeComb=new Ext.form.ComboBox({ margins:'0 0 0 0', fieldLabel: '证书类型', displayField:'certificateTypeName', valueField:'certificateTypeId', allowBlank:true, height: 25, anchor: '95%', editable : false, mode:'local', store:certifcateTypeStore, triggerAction : 'all' }); certifcateLevelStore= new Ext.data.JsonStore({ fields:['certificateLevel'] }); var qytg_certificateLevelComb=new Ext.form.ComboBox({ margins:'0 0 0 0', //disabled:true, //forceSelection: true, fieldLabel: '证书等级', displayField:'certificateLevel', valueField:'certificateLevel', allowBlank:true, anchor: '95%', editable : false, mode:'local', store:certifcateLevelStore, triggerAction : 'all' }); qytg_certificateTypeComb.on('select', function (combo, record,index) { qytg_certificateLevelComb.clearValue(); Ext.Ajax.request({ url :'../getCertificateLevelList', mthod : 'post', params:{ certificateID:qytg_certificateTypeComb.getValue() }, success : function(response) { var result = Ext.util.JSON.decode(response.responseText); qytg_certificateLevelComb.getStore().loadData(result.levellist); } }) ; } );