jstree 使用-层次-搜索


jstree 中文帮助文档:http://blog.csdn.net/qq_24472595/article/details/70053863#search

创建后的没有层次的树如下

jstree 使用-层次-搜索_第1张图片

树的源码和树的结构如下:

 @At
    @Ok("json")
    @RequiresPermissions("o2omarket.ProcurementCar")
    public Object tree(@Param("pid") String pid) {
//      List list = cmsChannelService.query(Cnd.where("parentId", "=", Strings.sBlank(pid)).asc("location").asc("path"));
    	List list = null;
    	if (pid != null && pid.toLowerCase().indexOf("shopsearch") != -1) {
    		if (pid.split(",") != null && pid.split(",").length > 1){
	    		SqlExpressionGroup e1 = Cnd.exps("fdShopName", "LIKE", "%" + pid.split(",")[1]+"%").and("1", "=", "1");
	    		list = shopService.query(Cnd.where(e1));
    		}
    		else 
    			list = shopService.query(Cnd.where("1","=","1"));
    	} 
    	else 
    		list = shopService.query(Cnd.where("1","=","1"));
        List> tree = new ArrayList<>();
        for (Shop shop : list) {
            Map obj = new HashMap<>();
            obj.put("id", shop.getFdShopId());
            obj.put("text", shop.getFdShopName());
            tree.add(obj);
        }
        return tree;
    }    
<%
layout("/layouts/platform.html"){
%>




<%}%>




创建有层次的树如下:

jstree 使用-层次-搜索_第2张图片


<% layout("/layouts/platform.html"){ %>




<%}%>
@At
	@Ok("json")
	@RequiresPermissions("o2omarket.monthWarranty")
	public Object tree(@Param("pid") String pid ,@Param("site") String site) {
		List> tree = new ArrayList<>();
		// List list =
		// cmsChannelService.query(Cnd.where("parentId", "=",
		// Strings.sBlank(pid)).asc("location").asc("path"));
		// List list = shopService.query(Cnd.where("1","=","1"));
		if (StringUtils.isBlank(pid)) {
			List list = bu_FloorService.query(Cnd.NEW().asc("fdFlooSort"));
			for (BU_Floor shop : list) {
				Map obj = new HashMap<>();
				obj.put("id",  shop.getFdFlooId());
				obj.put("text", shop.getFdFlooName());
			    obj.put("children", true);
				tree.add(obj);
			}
		} else {
			Cnd cnd = null;
			//-99无意义,仅为空字符串查询全部数据而已 modify by william
			if (!pid.equalsIgnoreCase("-99")) 
				cnd=Cnd.where("fdShopFloor", "=", pid);
			else 
				cnd=Cnd.where("1","=" ,"1");
			
			//cnd.desc("licensePlate");
			if(StringUtils.isNotBlank(site))
			{
				cnd=cnd.and("fdShopNum","like" ,"%"+site+"%");
			}
			/*List list = viewMonthWarrantyShopService
					.query(cnd.desc("licensePlate").asc("fdShopNum"));*/
			List list = null;
	    	if (pid != null && pid.toLowerCase().indexOf("shopsearch") != -1) {
	    		if (pid.split(",") != null && pid.split(",").length > 1 && !StringUtils.isEmpty(pid.split(",")[1])){
		    		SqlExpressionGroup e1 = Cnd.exps("fdShopName", "LIKE", "%" + pid.split(",")[1]+"%").and("1", "=", "1");
		    		list = viewMonthWarrantyShopService.query(Cnd.where(e1));
	    		}
	    		else 
	    			list = viewMonthWarrantyShopService.query(cnd.desc("licensePlate").asc("fdShopNum"));
	    	} 
	    	else 
	    		list = viewMonthWarrantyShopService.query(cnd.desc("licensePlate").asc("fdShopNum"));
	    	// modify by william
			for (View_MonthWarrantyShop shop : list) {
				Map obj = new HashMap<>();
				obj.put("id", shop.getFdShopId());
				obj.put("text", shop.getFdShopName()
						+ (StringUtils.isBlank(shop.getFdShopNum()) ? "" : ("(" + shop.getFdShopNum() + ")"))
						+ (StringUtils.isBlank(shop.getLicensePlate()) ? "" : ("[" + shop.getLicensePlate() + "]")));
				 obj.put("children", false);
				tree.add(obj);
			}
		}
		return tree;
	}








你可能感兴趣的:(javaweb)