@RequestMapping(params = "datagrid")
public void datagrid(ProjectGoabroadStudentEntity projectGoabroadStudent,HttpServletRequest request, HttpServletResponse response,DataGrid dataGrid) {
CriteriaQuery cq = new CriteriaQuery(ProjectGoabroadStudentEntity.class, dataGrid);
// 查询条件组装器
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq,projectGoabroadStudent, request.getParameterMap());
try {
// 自定义追加查询条件
插入查询的条件
} catch (Exception e) {
throw new BusinessException(e.getMessage());
}
cq.add();
this.projectGoabroadStudentService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);
}
要插入的查询条件
String sql1=" SELECT * FROM t_s_user t where 1=1";
String sql2=" SELECT count(*) FROM t_s_user t where 1=1";
// 某一个时间条件的案例
String mwo_reporting_time_begin1 = "2015-01-01";
String mwo_reporting_time_end2 = "2019-12-31";
if (StringUtil.isNotEmpty(mwo_reporting_time_begin1)) {
sql1+=" and create_date>'"+mwo_reporting_time_begin1+"'";
sql2+=" and create_date>'"+mwo_reporting_time_begin1+"'";
}
if (StringUtil.isNotEmpty(mwo_reporting_time_end2)) {
sql1+=" and create_date<'"+mwo_reporting_time_end2+"'";
sql2+=" and create_date<'"+mwo_reporting_time_end2+"'";
}
sql1+=" GROUP BY id order by create_date desc";
sql2+=" GROUP BY id ";
// 获取总数,用于分页使用
long countMwo = systemService.getCountForJdbc(sql2);
// 转换为 int 整形
int allCounts = (int)countMwo;
int pageSize = cq.getPageSize();// 每页显示数
int curPageNO = PagerUtil.getcurPageNo(allCounts, cq.getCurPage(),pageSize);// 当前页
//findForJdbc(sql1); sql
//findHql(hql1); hql
// 获取数据列表,参数一:查询的sql、参数二三:当前页码、数据总数
List<Map<String, Object>> listMwo=systemService.findForJdbc(sql1, curPageNO, pageSize);
cq.getDataGrid().setResults(listMwo);
cq.getDataGrid().setTotal(allCounts);
其他Jeecg datagrid 使用方法URL:1、https://www.cnblogs.com/xujiating/p/10942784.html
2、https://wenku.baidu.com/view/8d4dcc2aae1ffc4ffe4733687e21af45b307fee6.html