日期:2014-05-16 浏览次数:20590 次
var provinces = [[1, '北京'], [2, '上海']]; var cities = new Array(); cities[1] = [[11, '海淀'], [22, '东城']]; cities[2] = [[33, '黄埔'], [44, '浦东'], [55, '静安']]; var comboProvinces = new Ext.form.ComboBox({ store : new Ext.data.SimpleStore({ fields : ["provinceId", "provinceName"], data : provinces }), listeners : { select : function(combo, record, index) { comboCities.clearValue(); comboCities.store.loadData(cities[record.data.provinceId]); } }, valueField : "provinceId", displayField : "provinceName", mode : 'local', forceSelection : true, blankText : '请选择省份', emptyText : '请选择省份', hiddenName : 'provinceId', editable : false, triggerAction : 'all', allowBlank : true, fieldLabel : '所在省市', name : 'provinceId', anchor:'90%' }); var comboCities = new Ext.form.ComboBox({ store : new Ext.data.SimpleStore({ fields : ["cityId", 'cityName'], data : [] }), valueField : "cityId", displayField : "cityName", mode : 'local', forceSelection : true, blankText : '选择地区', emptyText : '选择地区', hiddenName : 'cityId', editable : false, triggerAction : 'all', allowBlank : true, //fieldLabel : '选择地区', labelWidth:0, name : 'cityId', anchor:'90%' }); new Ext.form.FormPanel({ title:'添加用户', width:350, id:'frm', renderTo:'myForm', frame:true, bodyStyle:"padding:5px 5px 0", labelAlign:'right', labelWidth:60, layout:'form', items:[{ layout:'column', items:[{ columnWidth:.9, layout:'form', items:[{ xtype:'textfield', fieldLabel:'用户名', id:'username', anchor:'95%' }] },{ columnWidth:.9, layout:'form', items:[{ xtype:'textfield', fieldLabel:'密 码', inputType:'password', id:'userpass', anchor:'95%' }] },{ columnWidth:.5, layout:'form', items:[comboProvinces] },{ columnWidth:.5, layout:'form', items:[comboCities] }] }], buttons:[{text:"确定",handler: submitForm},{text:"取消"}], buttonAlign:'center' });