因项目需要,做了这个,发上来给大家参考一下,呵呵。
- var provinceComBo=new Ext.form.ComboBox({
- hiddenName:'province',
- name: 'province_name',
- valueField:"text",
- displayField:"text",
- mode:'local',
- fieldLabel: '所在省份',
- blankText:'请选择省份',
- emptyText:'请选择省份',
- editable:false,
- anchor:'90%',
- forceSelection:true,
- triggerAction:'all',
- store:new Ext.data.SimpleStore({fields: ["text","city"],data:citys,sortInfo:{field:'text'}}),
- listeners:{
- select:function(combo, record,index){
- cityCombo.clearValue();
- cityCombo.store.loadData(record.data.city);
- }
- }
- })
- var cityCombo=new Ext.form.ComboBox({
- hiddenName:'city',
- name:'city_name',
- valueField:"text",
- displayField:"text",
- mode:'local',
- fieldLabel: '所在城市',
- blankText:'请选择城市',
- emptyText:'请选择城市',
- editable:false,
- anchor:'90%',
- forceSelection:true,
- triggerAction:'all',
- store:new Ext.data.SimpleStore({fields: ["text"],data:[],sortInfo:{field:'text'}})
- });
comboBox的其它定义我就不详细说了,有兴趣可以参考我的文章《Ext2.0 form使用实例》。我们重点研究一下它的sotre的定义。省份的store定义如下:
- store:new Ext.data.SimpleStore({fields: ["text","city"],data:citys,sortInfo:{field:'text'}}),
- listeners:{
- select:function(combo, record,index){
- cityCombo.clearValue();
- cityCombo.store.loadData(record.data.city);
- }
- }