好记性不如烂笔头,个人笔记,不具备参考价值。
新环境,用EasyUi做页面,先来个Grid。
页面先定义grid的div:
<div data-options="region:'center',border:false" id="aqyygrid">
</div>
在js文件中这么定义:
var qyyd_main = {
addWindowOpened:false,
sjlx:null,
sjgl_datagrid:function(){
$('#aqyygrid').datagrid({
url: context + "/aqyy/aqyyList.action",
loadMsg:'正在加载数据...',
singleSelect: true,
fit:true,
border:false,
rownumbers:true,
pagination:true,
pageNumber : 1,
pageSize : 15,
pageList : [5,15,30,45,60],
queryParams: {
},
columns:[[
{field:'bxr',title:'被保险人',width:90,align:'center',
formatter : function(value, rowData, rowIndex) {
return rowData.BXR;
}
},
{field:'cph',title:'车牌号',width:90,align:'center',
formatter : function(value, rowData, rowIndex) {
return rowData.CPH;
}
},
{field:'basj',title:'报案时间',width:150,align:'center',
formatter : function(value, rowData, rowIndex) {
return rowData.BASJ;
}
},
{field:'cxsj',title:'出险时间',width:150,align:'center',
formatter : function(value, rowData, rowIndex) {
return rowData.CXSJ;
}
},
{field:'qbrq',title:'起保日期',width:150,align:'center',
formatter : function(value, rowData, rowIndex) {
return rowData.QBRQ;
}
},
{field:'larq',title:'立案日期',width:150,align:'center',
formatter : function(value, rowData, rowIndex) {
return rowData.LARQ;
}
},
{field:'laje',title:'立案金额',width:60,align:'center',
formatter : function(value, rowData, rowIndex) {
return rowData.LAJE;
}
},
{field:'cxdd',title:'出险地点',width:150,align:'center',
formatter : function(value, rowData, rowIndex) {
return rowData.CXDD;
}
},
{field:'zrb',title:'责任比',width:60,align:'center',
formatter : function(value, rowData, rowIndex) {
return rowData.ZRB;
}
},
{field:'ssrs',title:'受伤人数',width:60,align:'center',
formatter : function(value, rowData, rowIndex) {
return rowData.SSRS;
}
},
{field:'swrs',title:'死亡人数',width:60,align:'center',
formatter : function(value, rowData, rowIndex) {
return rowData.SWRS;
}
}
]]
});
},aqyySearch:function(){//这儿定义点击按钮的时候的查询方法。
var query = {
"bxr":$("#bxr1").val(),
"cph":$("#cph1").val(),
"zyzr":$("#zr").val()
};
$("#aqyygrid").datagrid('options').queryParams = query; //把查询条件赋值给datagrid内部变量
$("#aqyygrid").datagrid('options').pageNumber = 1;
$('#aqyygrid').datagrid('reload');
}
};
$(function(){
qyyd_main.sjgl_datagrid();//页面加载完之后查询列表
$("#cx1").click(function(){//点击查询按钮
qyyd_main.aqyySearch();
});
});
action中查询数据库:
/**
* 进入安全运营列表页面时ajax方法
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
@Action(value = "aqyyList")
public String aqyyList() throws Exception {
String hql = "SELECT id,bxr,cph,to_char(basj,'yyyy-mm-dd hh24:mi:ss') basj,to_char(cxsj,'yyyy-mm-dd hh24:mi:ss') cxsj,to_char(qbrq,'yyyy-mm-dd') qbrq,to_char(larq,'yyyy-mm-dd') larq,laje,cxdd,zrb,ssrs,swrs from t_kp_qyyd_aqyy " +
"WHERE bxr LIKE ? AND cph LIKE ? AND zyzr=?";
List<Object> args = new ArrayList<Object>();
bxr = bxr==null||bxr.equals("")?"":bxr;
cph = cph==null||cph.equals("")?"":cph;
zyzr = zyzr==null||zyzr.equals("")?"1":zyzr;
args.add("%"+bxr+"%");
args.add("%"+cph+"%");
args.add(zyzr);
if(page==0){
page=1;
}
if(rows==0){
rows=10;
}
para.setPageNo(page);
para.setPageSize(rows);
Map map = GridMap.sqlSearch(hql, args, para);
return renderJsonRefer(map,"list");
}