关闭

Js-easyui初始化树

标签: easyui初始化树
854人阅读 评论(0) 收藏 举报
分类:
<body>
<jsp:include page="/av/top.jsp"></jsp:include>
<jsp:include page="/av/module/head.jsp"></jsp:include>
<!-- nav -->
<div class="zsnavigation">aa<img src="av/images/erjidhimg.png" />发布aa</div>
<!-- main -->
<div class="zserjimain">
	<div id="leftTree" class="zsermleft" style="overflow-y:auto ;height:480px;width:199px;border:0px solid black;">
		<ul id="mytree" style="height:190px;"> </ul>  
	</div>
	<div id="rightPage" class="zsermright">
		<iframe id="dynaPage" src="<%=request.getContextPath()%>/av/module/knowledge/knowledgePublish/dynaPage.jsp"  frameborder="0"  width="100%" onload="dyniframesize('dynaPage');"></iframe>
	</div>
</div>
<!-- 
<div id="mm" class="easyui-menu" style="width: 120px;">
	<div onclick="MenuWin()" iconcls="icon-add">添加子菜单</div>
	<div onclick="updateMenu()" iconcls="icon-edit">修改</div>
	<div onclick="delMenu()" iconcls="icon-remove">删除</div>
</div>
 -->
<div id="zhsh_foot">© 2013 </div>

<script type="text/javascript">
var baseurl = '<%=request.getContextPath()%>';

$(function(){
 	loadProcessTree();
 	dyniframesizeDiv("leftTree");
 	window.setTimeout("expand()", 400);
});

function loadProcessTree(id){
	$('#mytree').tree({   
		checkbox: false,   
		lines : true,
		method : 'post',
		iconCls: 'icon-catalog',
	    url:'pl/templateClass/getTemplateClassTreeRoot.json?rootId='+(id==undefined||id==""?"KnowledgeTemplateClass":id),  
	    onBeforeExpand:function(node,param){
	    	 $('#mytree').tree('options').url = "pl/templateClass/getChildNodeWithPrivilege.json?parentId=" + node.id ;
	    	 $('#mytree').tree('update', {
	             target: node.target,
	             iconCls: 'icon-file'
	         });
	    },
	    onClick:function(node){
	    	var b = $("#tree").tree('isLeaf',node.target);
	    	//document.getElementById("listTable").src="pl/template/templateListByclassId?tableName="+node.attributes.tableName;
	    	if(b){
	    		getTemplateForPublish(node);
	    	}else{
	    		getIntroductionInfo(node);
	    	}
      	},
      	onContextMenu: function(e, node){  
            e.preventDefault();  
            $('#mytree').tree('select', node.target);  
            $('#mm').menu('show', {  
                left: e.pageX,  
                top: e.pageY  
            });  
        }
	});
}

function getIntroductionInfo(node){
	expand();
	if(node){
		window.frames['dynaPage'].loadIntroduction(node.id);
	}
}
function getTemplateForPublish(node){
	if(node){
		if(node.attributes && node.attributes.tableName){
			var tableName=node.attributes.tableName;
			window.frames['dynaPage'].loadTemplage(tableName);
		}
	}
}

function expand() {
	var node = $('#mytree').tree('getSelected');
	if(node){
		$('#mytree').tree('expand',node.target);
	}else{
		$('#mytree').tree('expandAll');
	}
}
</script>
</body>

 

/**
	 * 
	 * @return Collection 树的根,
	 * @throws Exception
	 */
	@RequestMapping("/getTemplateClassTreeRoot")
	public void getTreeRoot(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String roodId = request.getParameter("rootId");
		List<KmTemplateClass> classList = templateClassService
				.getTreeRoot(roodId);
		List<BmpCatalogTreeModel> resultList = templateClassService
				.getCatalogTreeDataJson(classList);

		ObjectMapper mapper = new ObjectMapper();
		String dataStr = mapper.writeValueAsString(resultList);
		response.getWriter().write(dataStr);
		response.getWriter().flush();
		response.getWriter().close();
	}


 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:39023次
    • 积分:732
    • 等级:
    • 排名:千里之外
    • 原创:30篇
    • 转载:32篇
    • 译文:0篇
    • 评论:1条
    最新评论