ALIAS_TO_ENTITY_MAP 封装成对象
protected List<?> executeSQLMapQuery(String sql, Object param, int start,
int limit) {
Query query = null;
query = this.getSession().createSQLQuery(sql)
.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
setParameter(query, param);
resumeIdx();
if (start != -1 || limit != -1) {
query.setFirstResult(start);
query.setMaxResults(limit);
}
return query.list();
}
List<?> list = this.executeSQLMapQuery( searchSql, newParams, ( pageRequest.getPage() - 1 ) * pageRequest.getRows(), pageRequest.getRows() );
List<Map<String,String>> result = (List<Map<String,String>>)list;
//调用时,result是无序的。result.get(0).get(列名);获得第一列的数据。
如果不设置.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
那么返回的是List<Object[]> objectList = query.list();对象,是按照sql写的先后顺序出来的。
objectList.get(0)[0]才是第一列的数据
获取datagrid的页码传到后台
function auditDealModify(){
var pager = $(‘#tt‘).datagrid(‘getPager‘);
var options = $(‘#tt‘).datagrid(‘getPager‘).data("pagination").options;
var page = options.pageNumber;
var rows = options.pageSize;
window.open(‘<z:ukey key="exportTemplateController_exportExcleByTemplate" context="admin" />?page=‘+page+‘&rows=‘
+rows+‘&serviceBeanName=cashReportServiceImpl&templateName=本金&className=year,month‘
+‘&itemOrder=isClear,loanNo,loanSubjectName,intRate,period,applyloanDt,applyRepayDt,amount,maxRepay,realPaid,balance,curPri,curpriAmount,curOwn‘ );
}
生成年月下拉框
var curYear = new Date().getFullYear();
var curMonth=new Date().getMonth()+1;
yearOption = [];
for(i=0;i<10;i++)
yearOption.push({ "text": curYear-i , "value": curYear-i });
$("#m_year").combobox("loadData", yearOption);
$("#m_year").combobox("setValue",curYear);
monthOption= [];
for(i=1;i<13;i++)
monthOption.push({ "text": i , "value": i });
$("#m_month").combobox("loadData", monthOption);
$("#m_month").combobox("setValue",curMonth);