JS代码:
function toStepGrid(id) {
/*此处id是可以获取到的传值*/
$('#stepGrid').datagrid({
title:'流程',
pageSize:20,
fitColumns:true,
pagination:true,
rownumbers:true,
singleSelect:true,
url: 'admin/findStep?id='+id,
columns:[[
{field:'name',title:'流程名',width:50},
{field:'id',title:'待定',width:50},
]]
});
}
后台:
controller:
@ResponseBody
@RequestMapping("/findStep")
public Map<Object, Object> findStep(HttpServletRequest request, Model model){
String str = request.getParameter("id");
Long stepId = Long.parseLong(str);
Map<Object, Object> map = formService.findStep(stepId);
System.out.println("id==>"+map.get("id"));
return map;
}
Service:
public Map<Object, Object> findStep(Long stepId) throws ServiceException {
Map<Object, Object> map = new HashMap<>();
map = baseDao.find("select id,name from step where id=?", stepId).get(0);
List<Step> steps = baseDao.findAll("from Step s where s.id=?", stepId);
System.out.println("Service: name==>"+map.get("name"));
return map;
}
解决了,service层查询用分页
```public Map findFormByStep(Long stepId, int start, int limit) throws ServiceException {
StringBuffer sql = new StringBuffer("select name,dvalue,type,dialog,width,height from form f,form_step fs where f.id=fs.form_id and fs.step_id=").append(stepId);
Map map = baseDao.findAllforPage(sql.toString(), start, limit);
@SuppressWarnings("unchecked")
List> rows=(List>) map.get("rows");
for (Map row : rows) {
List> steps = baseDao.find("select s.name from form_step fs left join step s on s.id=fs.step_id where fs.form_id="+row.get("id"));
StringBuffer temp = new StringBuffer();
row.put("steps", temp);
}
return map;
}