extjs 省市县 读取

    var provinceCode = '';
    var cityCode = '';
    var areaCode = '';
//编辑显示
	var editStore = new Ext.data.Store({
 		proxy : new Ext.data.HttpProxy({
			url : getContextPath()+'/grid!toEdit.asp?vo.major=10201'//TODO
		}),
		reader : new Ext.data.JsonReader({
			root : 'data',
			totalProperty : 'totalCount',
			idProperty : 'id'
		}, [
			{name : 'id',mapping : 'id'},
			{name : 'name',mapping : 'name'},
			{name : 'sex',mapping : 'sex'},
			{name : 'nation',mapping : 'nation'},
			{name : 'college',mapping : 'college'},
			{name : 'major',mapping : 'major'},
			{name : 'grade',mapping : 'grade'},
			{name : 'classs',mapping : 'classs'},
			{name : 'idcard',mapping : 'idcard'},
			{name : 'birth',mapping : 'birth'},
			{name : 'politicalstatus',mapping : 'politicalstatus'},
			{name : 'phone',mapping : 'phone'},
			{name : 'originnum',mapping : 'originnum'},
			{name : 'detailAddress',mapping : 'detailAddress'},
			{name : 'municipiosnum',mapping : 'municipiosnum'},
			{name : 'homephone',mapping : 'homephone'},
			{name : 'schoolstatus',mapping : 'schoolstatus'},
			{name : 'medicalinsurance',mapping : 'medicalinsurance'},
		    {name : 'commerciaLinsurance',mapping : 'commerciaLinsurance'},
		    {name : 'originLoan',mapping : 'originLoan'},
			{name : 'countryLoan',mapping : 'countryLoan'},
			{name : 'poorStudent',mapping : 'poorStudent'},
			{name : 'dormitorybuild',mapping : 'dormitorybuild'},
			{name : 'dormitorynum',mapping : 'dormitorynum'},
			{name : 'province',mapping : 'province'},
			{name : 'city',mapping : 'city'},
			{name : 'area',mapping : 'area'}
		])
	});
//省
	var addprovinceStore = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : getContextPath()+"/area!province.asp"
		}),
		reader : new Ext.data.JsonReader({
			root : 'data',
			id : 'provinceId'
		},[ {
			name : 'provinceId',
			mapping : 'provinceId'
		}, {
			name : 'provinceCode',
			mapping : 'provinceCode'
		}, {
			name : 'provinceName',
			mapping : 'provinceName'
		}]),listeners: {
      	load: function() {
           addprovinceCombobox.setValue(provinceCode );
<pre name="code" class="javascript">           provinceCode='';
      }
}
	});
	addprovinceStore.load();
	var addprovinceCombobox = new Ext.form.ComboBox({
		id:'addprovince',
		width:122,
        fieldLabel:'省',
        name:'province',
        hiddenName:'province',
        mode:'local',
        editable: false,
       	valueField: 'provinceCode',
        displayField: 'provinceName',
        triggerAction:'all',
        store: addprovinceStore,
		listeners : {
			'select' : function(combo, record, index) {
				addcityStore.proxy = new Ext.data.HttpProxy({
					url : getContextPath()+'/area!city.asp?vo.provinceCode=' + combo.value
				});
				addcityCombobox.clearValue();
				addcityStore.load();
			}
		}
	});
	//市
	var addcityStore = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : getContextPath()+"/area!city.asp"
		}),
		reader : new Ext.data.JsonReader({
			root : 'data',
			id : 'cityId'
		},[ {
			name : 'cityId',
			mapping : 'cityId'
		}, {
			name : 'cityName',
			mapping : 'cityName'
		}, {
			name : 'cityCode',
			mapping : 'cityCode'
		}]),listeners: {
      	load: function() {
           addcityCombobox.setValue(cityCode);
           cityCode='';
     	 }
      }
	});
	var addcityCombobox = new Ext.form.ComboBox({
		id:'addcity',
		width:122,
        fieldLabel:'市',
        name:'city',
        hiddenName:'city',
        mode:'local',
        editable: false,
       	valueField: 'cityCode',
        displayField: 'cityName',
        triggerAction:'all',
        store: addcityStore,
		listeners : {
			'select' : function(combo, record, index) {
				addareaStore.proxy = new Ext.data.HttpProxy({
					url : getContextPath()+'/area!area.asp?vo.cityCode=' + combo.value
				});
				addareaCombobox.clearValue();
				addareaStore.load();
			}
		}
	});
	//县
	var addareaStore = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : getContextPath()+"/area!area.asp"
		}),
		reader : new Ext.data.JsonReader({
			root : 'data',
			id : 'areaId'
		},[ {
			name : 'areaId',
			mapping : 'areaId'
		}, {
			name : 'areaCode',
			mapping : 'areaCode'
		}, {
			name : 'areaName',
			mapping : 'areaName'
		}]),listeners: {
      	load: function() {
           addareaCombobox.setValue(areaCode);
           areaCode='';
     	 }
      }
	});
	var addareaCombobox = new Ext.form.ComboBox({
		id:'addarea',
		width:122,
        fieldLabel:'县',
        name:'area',
        hiddenName:'area',
        mode:'local',
        editable: false,
       	valueField: 'areaCode',
        displayField: 'areaName',
        triggerAction:'all',
        store: addareaStore
	});

editStore.load({
					params: {
						id: gridPanel.getSelectionModel().getSelected().data.id
					},
					callback: function(records, options, success){
						if(success){
							addForm.getForm().loadRecord(editStore.getAt(0));

							//TODO
							var num = editStore.getAt(0).data.municipiosnum;
                                                        provinceCode = num.substring(0,2)+'0000';
                                                        cityCode = num.substring(0,4)+'00';
							areaCode = num;
							addcityStore.proxy = new Ext.data.HttpProxy({
								url : getContextPath()+'/area!city.asp?vo.provinceCode=' + num.substring(0,2)+'0000'
							});
							addcityCombobox.clearValue();
							addcityStore.load();

							addareaStore.proxy = new Ext.data.HttpProxy({
								url : getContextPath()+'/area!area.asp?vo.cityCode=' + num.substring(0,4)+'00'
							});
							addareaCombobox.clearValue();
							addareaStore.load();

							}else{
							showErrorMsg("加载学生信息失败,请刷新数据后重试",gridPanel);
						}
					}
				});
			addWin.setTitle("修改学生");
			addWin.show();
			addForm.getForm().enableAll();
			addForm.getForm().findField('addid').disable();
		}

时间: 2024-10-08 14:14:20

extjs 省市县 读取的相关文章

Extjs的数据读取器store和后台返回类型简单解析

工作中用到了Extjs,从后台获取数据的时候,用到了extjs自己的Ext.data.store方法,然后封装了ExtGridReturn方法, 目的:前台用到Ext.data.store读取从后台传过来的数据,后台封装成ExtGridReturn类型 前台如下: this.store = new Ext.data.Store({            remoteSort:true,            baseParams:{                start:0,        

ExtJs之Ext.comboBox的远程数据源读取程序

既然可以测试本地AJAX,那就把书前面的代码作一次学习吧. <!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="te

Extjs读取更改或者发送ajax返回请求的结果简单封装

Extjs的submit()方法提交的数据:如下: this.formPanel.getForm().submit({                url:this.saveUrl,                method:'POST',                params:{                    flag:e                },                success:function(form,action){              

Eclipse读取含有extjs的项目文件时卡死或者编写ExtJS时卡

关于Eclipse\MyEclipse下加入Ext卡的解决方案: 打开Eclipse的workspace下该项目对应.project文件 删除以下内容: (1) <buildCommand> <name>org.eclipse.wst.jsdt.core.javascriptValidator</name> <arguments> </arguments> </buildCommand> (2) <nature>org.e

Extjs读取本地下拉选框数据源,分为text和value,显示text,传值value

this.rdTypeCom=new Ext.form.ComboBox({              hiddenName:'rdType',              store:new Ext.data.SimpleStore(              {               fields:['value','text'],               data:[['1','金钱奖励'],['2','名誉奖励'],['3','惩罚']]              }),    

js读取json文件的方式——原生js,juqery,extjs

原生js 一,ajax方式. var xmlhttp=new XMLHttpRequest();xmlhttp.open('get','json/data.json',true);xmlhttp.send(null);xmlhttp.onreadystatechange=function(){ if(xmlhttp.readyState==4) { if(xmlhttp.status==200){ console.log(json_encode(xmlhttp.responseText)); }

struts extjs 3.3.1 读取JSON文件

json文件和脚本代码: jsonSrc/jsonTxt1.json, { "personInfoList": [ { "id": 0, "name": "A", "age": 12 }, { "id": 1, "name": "B", "age": 32 }, { "id": 2, "name&q

extjs中grid对于其中表单的表头的读取以及是否隐藏的判断

//获取grid的表头信息 var columns=baseGrid.columns;                     alert(columns.length); //判断列是否隐藏并输出表头名                    Ext.each(columns,function(column){                        if(!column.isHidden()){                            alert(column.text);

ExtJs之Ext.data.Store

ExtJs之Ext.data.Store Posted on 2009-07-21 09:09 linFen 阅读(44912) 评论(5) 编辑 收藏 Store.getCount()返回的是store中的所有数据记录,然后使用for循环遍历整个store,从而得到每条记录. 除了使用getCount()的方法外,还可以使用each()函数,如下面的代码所示. store.each(function(record) { alert(record.get('name')); }); Each()