日期:2014-05-16  浏览次数:20461 次

ExtJs3.4项目应用备忘--PAJZ12RepInfo.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<html>
<head>
	<title>化验信息</title>
	<!-- 页面编码方式最好是utf-8,否则使用ext有可能乱码 -->
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/extjs/resources/css/ext-all.css" />
	<script type="text/javascript" src="<%=request.getContextPath()%>/extjs/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/extjs/ext-all.js"></script>
	<!-- 注意:引入本地化文件最好加上 charset="utf-8",这样如果页面编码方式不是utf-8,ext中也不会出现乱码。-->
    <script type="text/javascript" src="<%=request.getContextPath()%>/extjs/ext-lang-zh_CN.js" charset="utf-8"></script>
	
	<script type="text/javascript">

		Ext.onReady(function(){
		
			var comms = "";
			var oth = "";
			// 获得父窗口的对象   
		   	var parentwin = window.dialogArguments;
		   	var sqbh = parentwin.document.getElementsByName("SQBH")[0].value; //申请编号
		   	var nd = sqbh.substring(0,4);//年度
			var sqdw = parentwin.document.getElementsByName("SQDW")[0].value;//申请单位
			var xmz = sqdw.split("┆")[0];//项目组
			var dq = parentwin.document.getElementById("dq").value;//地区
		   	var jh = parentwin.document.getElementById("jh").value; //井号
		   	var cw = parentwin.document.getElementById("cw").value; //层位
		   	//获取查询参数
			var params = parentwin.document.getElementById("addReInfo").value; //获取查询结果;
			if(params != null){
				var arr = params.split("==");
				comms = arr[0];
				oth = arr[1];
			}
			
			//列定义
		    var cm = new Ext.grid.ColumnModel([
		        new Ext.grid.RowNumberer(),//生成编号
		        {
		        	header:'<center>分析化验项目</center>', //列名称
		        	dataIndex:'FXHYXM', //列对应的字段
		        	width:150 //列宽度
		        },
		        {
		        	header:'<center>采样规格</center>', 
		        	dataIndex:'CYGG', 
		        	width:150,
		        	editor: new Ext.grid.GridEditor( //可以编辑
			            new Ext.form.TextField({ //普通的文本输入框
			                allowBlank: false //不允许填充空值
			            })
        		 	)
		        },
		        {
		        	header:'<center>采样数量</center>', 
		        	dataIndex:'CYSL',
		        	width:50,
		        	align:'right',
		        	editor: new Ext.grid.GridEditor( 
			             new Ext.form.NumberField({ //数字输入框
			                allowBlank: false,
			                allowNegative:false
			            })
        		 	)
		        },
		        {
		        	header:'<center>备注</center>', 
		        	dataIndex:'BZ',
		        	width:150,
		        	editor: new Ext.grid.GridEditor(
			            new Ext.form.TextField({
			                allowBlank: true
			            })
        		 	)
		        }
		    ]);
		    
		    //定义记录集模型
		    var Record = Ext.data.Record.create([
		        {name: 'FXHYXM', type: 'string'},
		        {name: 'CYGG', type: 'string'},
		        {name: 'CYSL', type: 'string'},
		        {name: 'BZ', type: 'string'}
    		]);
	    	  
		    //数据源
		    var store = new Ext.data.Store({
		    	//请求参数,格式如下所示
		    	baseParams:{flg:'getExistPAJZ12Info',common:comms,others:oth},
		    	//代理
        		proxy: new Ext.data.HttpProxy({
		        	url:'<%=request.getContextPath()%>/pajz12Servlet',//请求路径
		        	method:'post'//url:请求路径;method:请求方式
		        }),
        		 //接受数据格式:json////////////////
		        reader: new Ext.data.JsonReader(
		        	//json格式,没有分页就不需要totalProperty属性
			        { root: 'root'}, 
			        //json中包含的属性
			        [
	            		{name: 'FXHYXM'},
			            {name: 'CYGG'},
			            {name: 'CYSL'},
			            {name: 'BZ'}
	        		]
        		)
    		});
    
    		//加载grid