Extjs4.2异步树样例

阅读更多

 

环境

Extjs 4.2.1

spring MVC 3.2.12

mybatis 3.2.8

 

效果图
Extjs4.2异步树样例_第1张图片

 

testTree.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% String path = request.getContextPath(); %>




testTree






	testTree
	

 

ResourceController的方法

@RequestMapping(value = "/getListByPU", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public List getListByPU(HttpServletRequest request, HttpServletResponse response, ModelMap model) throws IOException{
	//String node = request.getParameter("node");
	String id = request.getParameter("id");

	Map map = new HashMap();
	map.put("parentId", id);
	map.put("userId", getUser().getId());
	List resources = resourceSerive.getListByPU(map);
	List treeVos = new ArrayList();
	ExtTreeVo treeVo;
	for(Resource resource : resources){
		if(resource.getLeaf()){
			treeVo = new ExtTreeVo(resource.getId(),resource.getName(),true,"file");
		} else {
			treeVo = new ExtTreeVo(resource.getId(),resource.getName(),false,"folder");
		}
		treeVos.add(treeVo);
	}
	return treeVos;
}

 

ExtTreeVo

import java.util.List;

/** 
 * Ext树vo
 * @author happyqing
 * @date 2015-4-8
 */
public class ExtTreeVo {
	private long id;			//节点id
	private String text;		//文本
	private Boolean leaf;		//是否是叶子节点
	private String cls;			//样式
	private Boolean expanded;	//是否展开
	private List children;		//子节点列表
	
	public ExtTreeVo() {
	}
	
	public ExtTreeVo(long id, String text, Boolean leaf, String cls) {
		super();
		this.id = id;
		this.text = text;
		this.leaf = leaf;
		this.cls = cls;
	}
	
	//getter/sertter...

}

 

  • Extjs4.2异步树样例_第2张图片
  • 大小: 4.7 KB
  • 查看图片附件

你可能感兴趣的:(Extjs,tree,树,异步,加载)