前台的一个JS文件:/*
* 定义变量
* */
var myView;
var panel;
var myForm;
var date = new Date().format('Y-m-d');
var isORnot = '(√是/否)';
var haveORnot = '(√有/无)';
var store;
var queryFun;
var saveFun;Ext.onReady(function(){
Ext.BLANK_IMAGE_URL = '../../ext/resources/images/default/s.gif';
Ext.QuickTips.init(); //初始化信息提示功能
/*表格数据源*/
store = new Ext.data.Store({
proxy:new Ext.data.HttpProxy({url:'GasTableAction!findByMeterId.action'}),
reader:new Ext.data.JsonReader({
root:'JsonObjs'
},
[
{name:'auto_id'}, //自动id
{name:'METER_TYPE'}, //气表类型
{name:'METER_CAPACITY'}, //气表容量
{name:'METER_VENDOR'}
]
),
autoLoad:true,
softInfo:{field:'auto_id',direction:'DESC'} //排序
});
//实例化一个列模型对象
cm = new Ext.grid.ColumnModel([
//new Ext.grid.RowNumberer(),
{header:'自动id',width:100,dataIndex:'auto_id'},
{header:'气表类型',width:200,dataIndex:'METER_TYPE'},
{header:'表具容量',width:200,dataIndex:'METER_CAPACITY'},
{id:'vendor',header:'生产厂家',dataIndex:'METER_VENDOR'}
]);
//查询结果表格
grid = new Ext.grid.GridPanel({
width:812,
height:120,
//autoHeight:true,
cm:cm,
sm:new Ext.grid.RowSelectionModel({singleSelect:true}), //只允许单选
autoExpandColumn:'vendor',
autoScroll:true,
forceFit:true, //自动布局
store:store
});
/*气表编号*/
var meterId = new Ext.form.TextField({
name:'METER_ID',
id:'METER_ID',
maxLength:20,
listeners:{
'specialkey':function(f,e){
if(e.getKey()==Ext.EventObject.ENTER){
Ext.getCmp('chaxun').focus();
}
}
}
});
gasTabForm = new Ext.form.FormPanel({ //width:816,
height:482, //进驻项目的设置(设置了autoWidth和autoHeight不好使)
autoWidth:true,
frame:true, //panel的整个body区域全部填充背景并以圆角显示
labelSeparator:':', //分隔符
labelWidth:95, //文本框的宽度
labelAlign:'right', //位置设定
collapsible:true, //是否显示收缩按钮
bodyStyle:'padding:20px 10px',//方位顺序:上、左
layout:'form',
tbar:[
'气表编号:',meterId,
'-',
{
pressed:true,
iconCls:'select',
text:"查找",
id:'chaxun',
handler:function(){
store.load();
}
}
],
items:[ //使用feildset来对UI进行布局
{
xtype:'fieldset',
title:'查询结果',
autoWidth:true,
atuoHeight:true,
bodyStyle:'margin:10px 0px', //方位顺序:上、左、
layout:'column',
items:[
{
columnWidth:1,
layout:'form',
items:[grid]
}
]
}………………………………后面的我就不写了,上面是关键代码后台代码:我只写请求方法里面的处理过程::(GasTableAction中的方法)
public void findByMeterId()throws Exception{
try{
//前台参数
String keys=getRequest().getParameter("keys");
System.out.println(keys+"====================");
List<CmMeter> cmMeterList = cmMeterService.findCmMeterByMeterId(keys);
// ListRange<CmMeter> jsonrange=new ListRange();
// jsonrange.setTotalSize(cmMeterList.size());
// jsonrange.setList(cmMeterList);
// outJson(jsonrange,"yyyy-mm-ss");
// System.out.println("json 对象:"+jsonrange);
JSONObject jsonObj = new JSONObject();
JSONArray jsonArray = new JSONArray();
Iterator<CmMeter> it = cmMeterList.iterator();
int i = 0;
while(it.hasNext()){
CmMeter cm = (CmMeter)it.next();
JSONObject jsonObject = new JSONObject();
jsonObject.put("auto_id",(cm.getAutoId()==null||cm.getAutoId().equals(""))?"":cm.getAutoId());
jsonObject.put("METER_TYPE",(cm.getMeterType()==null||cm.getMeterType().equals(""))?"":cm.getMeterType());
jsonObject.put("METER_CAPACITY",(cm.getMeterCapacity()==null||cm.getMeterCapacity().equals(""))?"":cm.getMeterCapacity());
jsonObject.put("METER_VENDOR",(cm.getMeterVendor()==null||cm.getMeterVendor().equals(""))?"":cm.getMeterVendor());
jsonArray.put(i++, jsonObject);
}
jsonObj.put("jsonObjs",jsonArray);
outJsonString(jsonObj.toString());
System.out.println(jsonObj.toString());
}catch(Exception e){
e.printStackTrace();
}
}
* 定义变量
* */
var myView;
var panel;
var myForm;
var date = new Date().format('Y-m-d');
var isORnot = '(√是/否)';
var haveORnot = '(√有/无)';
var store;
var queryFun;
var saveFun;Ext.onReady(function(){
Ext.BLANK_IMAGE_URL = '../../ext/resources/images/default/s.gif';
Ext.QuickTips.init(); //初始化信息提示功能
/*表格数据源*/
store = new Ext.data.Store({
proxy:new Ext.data.HttpProxy({url:'GasTableAction!findByMeterId.action'}),
reader:new Ext.data.JsonReader({
root:'JsonObjs'
},
[
{name:'auto_id'}, //自动id
{name:'METER_TYPE'}, //气表类型
{name:'METER_CAPACITY'}, //气表容量
{name:'METER_VENDOR'}
]
),
autoLoad:true,
softInfo:{field:'auto_id',direction:'DESC'} //排序
});
//实例化一个列模型对象
cm = new Ext.grid.ColumnModel([
//new Ext.grid.RowNumberer(),
{header:'自动id',width:100,dataIndex:'auto_id'},
{header:'气表类型',width:200,dataIndex:'METER_TYPE'},
{header:'表具容量',width:200,dataIndex:'METER_CAPACITY'},
{id:'vendor',header:'生产厂家',dataIndex:'METER_VENDOR'}
]);
//查询结果表格
grid = new Ext.grid.GridPanel({
width:812,
height:120,
//autoHeight:true,
cm:cm,
sm:new Ext.grid.RowSelectionModel({singleSelect:true}), //只允许单选
autoExpandColumn:'vendor',
autoScroll:true,
forceFit:true, //自动布局
store:store
});
/*气表编号*/
var meterId = new Ext.form.TextField({
name:'METER_ID',
id:'METER_ID',
maxLength:20,
listeners:{
'specialkey':function(f,e){
if(e.getKey()==Ext.EventObject.ENTER){
Ext.getCmp('chaxun').focus();
}
}
}
});
gasTabForm = new Ext.form.FormPanel({ //width:816,
height:482, //进驻项目的设置(设置了autoWidth和autoHeight不好使)
autoWidth:true,
frame:true, //panel的整个body区域全部填充背景并以圆角显示
labelSeparator:':', //分隔符
labelWidth:95, //文本框的宽度
labelAlign:'right', //位置设定
collapsible:true, //是否显示收缩按钮
bodyStyle:'padding:20px 10px',//方位顺序:上、左
layout:'form',
tbar:[
'气表编号:',meterId,
'-',
{
pressed:true,
iconCls:'select',
text:"查找",
id:'chaxun',
handler:function(){
store.load();
}
}
],
items:[ //使用feildset来对UI进行布局
{
xtype:'fieldset',
title:'查询结果',
autoWidth:true,
atuoHeight:true,
bodyStyle:'margin:10px 0px', //方位顺序:上、左、
layout:'column',
items:[
{
columnWidth:1,
layout:'form',
items:[grid]
}
]
}………………………………后面的我就不写了,上面是关键代码后台代码:我只写请求方法里面的处理过程::(GasTableAction中的方法)
public void findByMeterId()throws Exception{
try{
//前台参数
String keys=getRequest().getParameter("keys");
System.out.println(keys+"====================");
List<CmMeter> cmMeterList = cmMeterService.findCmMeterByMeterId(keys);
// ListRange<CmMeter> jsonrange=new ListRange();
// jsonrange.setTotalSize(cmMeterList.size());
// jsonrange.setList(cmMeterList);
// outJson(jsonrange,"yyyy-mm-ss");
// System.out.println("json 对象:"+jsonrange);
JSONObject jsonObj = new JSONObject();
JSONArray jsonArray = new JSONArray();
Iterator<CmMeter> it = cmMeterList.iterator();
int i = 0;
while(it.hasNext()){
CmMeter cm = (CmMeter)it.next();
JSONObject jsonObject = new JSONObject();
jsonObject.put("auto_id",(cm.getAutoId()==null||cm.getAutoId().equals(""))?"":cm.getAutoId());
jsonObject.put("METER_TYPE",(cm.getMeterType()==null||cm.getMeterType().equals(""))?"":cm.getMeterType());
jsonObject.put("METER_CAPACITY",(cm.getMeterCapacity()==null||cm.getMeterCapacity().equals(""))?"":cm.getMeterCapacity());
jsonObject.put("METER_VENDOR",(cm.getMeterVendor()==null||cm.getMeterVendor().equals(""))?"":cm.getMeterVendor());
jsonArray.put(i++, jsonObject);
}
jsonObj.put("jsonObjs",jsonArray);
outJsonString(jsonObj.toString());
System.out.println(jsonObj.toString());
}catch(Exception e){
e.printStackTrace();
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货