1.A表字段:id,name;B表字段:id,name,fid(A表外键),现查询A表和B表的所有数据并且查询条件A,B都有,在前台页面list显示
2.后台方法:
@RequestMapping(params = "datagrid_zh")
public void datagrid_zh(CarRouteEntity ldcHandbookOrder,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
CriteriaQuery cq = new CriteriaQuery(CarRouteEntity.class, dataGrid);
//查询条件组装器
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, ldcHandbookOrder);
try{
//自定义追加查询条件
}catch (Exception e) {
throw new BusinessException(e.getMessage());
}
cq.add();
String tiaojian="";
String name=request.getParameter("name");
if(StringUtils.isNotEmpty(name)) {
tiaojian+=" and a.name>= '"+name+"'";
}
String sql="select a.id,a.name,b.name as bname from Aa LEFT JOIN B b on a.id=b.fid where 1=1 "+tiaojian;
List<Map<String, Object>> map=jdbcTemplate.queryForList(sql);
dataGrid.setTotal(map.size());
List<Map<String,Object>> maplist=systemService.findForJdbc(sql +" limit "+(dataGrid.getPage()-1)*dataGrid.getRows()+","+dataGrid.getRows(), null);
dataGrid.setResults(maplist);
TagUtil.datagrid(response, dataGrid);
}
3.前台页面
<t:datagrid name="??" checkbox="true" pagination="true" pageSize="10"
sortOrder="desc"
btnCls="bootstrap btn btn-success btn-xs"
fitColumns="false" title=""
actionUrl="??.do?datagrid_zh"
idField="id" fit="true" queryMode="group">
<t:dgCol title="id" field="id" hidden="true" queryMode="group" width="120"></t:dgCol>
<t:dgCol title="A表名称" field="name" query="true" width="120"></t:dgCol>
<t:dgCol title="B表名称" field="bname" query="true" width="120"></t:dgCol>
</t:datagrid>
4.技术问题联系微信xjt199561