您的位置:首页 > 产品设计 > UI/UE

EasyUI Sping MVC 树形网格 Treegrid 简单实例

2016-01-12 16:56 459 查看
JAP视图展示

@RequestMapping(value = "secondLevel")
@ResponseBody
public Object secondLevel(@RequestParam(value = "id", required = false) String id,
@RequestParam Integer page, @RequestParam Integer rows) {

//id为空位根节点,不为空可打开子节点

String idSql = StringUtil.isEmptyString(id) ? " is null " : " = " + id;

String strSql = "select t.id id,t.name name,t.begin begin,t.end end,t.progress progress," +
"decode(t.parentid,null,'closed','open') state " +
",t.parentid \"_parentId\",t.PERSONS persons from it  t where t.parentid " + idSql;

if (StringUtil.isEmptyString(id)) {
strSql = setPageSql(strSql, page, rows);
}

String countSql = "select count(*) from it t where t.parentid is null";

String personsSql = "select sum(PERSONS) from it t";

int count = jdbcTemplate.queryForInt(countSql);
int persons = jdbcTemplate.queryForInt(personsSql);
Map map = new HashMap();

try {
if (count > 0) {
List<TreeBean> treeBeans =
jdbcTemplate.query(strSql, BeanPropertyRowMapper.newInstance(TreeBean.class));
//total
map.put("total", count);
//rows
map.put("rows", treeBeans);
//footer
List<Map<String, Object>> footer = new ArrayList<Map<String, Object>>();
Map footermap = new HashMap();
footermap.put("name", "总人数");
footermap.put("persons", persons);
footermap.put("iconCls", "icon-sum");
footer.add(footermap);
map.put("footer", footer);
}
} catch (Exception ex) {
ex.printStackTrace();
}
return map;
}


JAVA
BEAN对象

private Long id;
private String name;
private String begin;
private String end;
private String progress;
private String _parentId;
private String persons;
private String state;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: