Home >Java >javaTutorial >Use of zTree tree plug-in--Introduction to asynchronous loading method
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>异步加载</title> <link rel="stylesheet"href="${pageContext.request.contextPath}/zTree_v3-master/css/demo.css?1.1.11"> <link rel="stylesheet"href="${pageContext.request.contextPath}/zTree_v3-master/css/zTreeStyle/zTreeStyle.css?1.1.11"> <script type="text/javascript"src="${pageContext.request.contextPath}/jquery-2.1.1.min.js?1.1.11"></script> <script type="text/javascript"src="${pageContext.request.contextPath}/zTree_v3-master/js/jquery.ztree.core.min.js?1.1.11"></script> <script type="text/javascript">var setting = { async : { enable : true, url : "${pageContext.request.contextPath}/ztreeAction!getMenusById.jhtml", autoParam : [ "id" ],//dataFilter : filter }, data : { key : { url : "xUrl"}, simpleData : { enable : true, pIdKey : "pid"} }, }; $(document).ready(function() { $.fn.zTree.init($("#treeDemo"), setting); });</script> </head> <body> <div class="ztree"style="width: 20%; height: 500px; padding-top: 10px; float: left; border: 1px solid #FF0000;"> <ul id="treeDemo"></ul> </div> </body> </html>
The above is the code of the jsp page. Because it is a pure plug-in test, you can directly copy the code used in the past.
action层代码,可以直接复制使用
public void getMenusById(){ List<Ztree> list=null;try { list=ztreeService.getMenusById(ztree); } catch (Exception e) { e.printStackTrace(); }super.writeJson(list); }
List<Ztree> getMenusById(Ztree ztree) Exception; //接口
"ztreeService" ZtreeServiceImpl List queryList(Ztree ztree) =" from Ztree where 1=1 "<String, Object> params = HashMap<String, Object>(ztree.getId()!=+=" and id = :id ""id" List<Ztree> getMenusById(Ztree ztree) =" from Ztree where 1=1 "<String,Object> params= HashMap<String,Object>(ztree.getId()==||ztree.getId().equals(""+=" and pid is null "+= " and pid = :id ""id"<Ztree> queryZtree =<Ztree> list= ArrayList<Ztree>"true" queryBoolean(Ztree ztree) flag== " from Ztree where pid = :id "<String,Object> params= HashMap<String,Object>"id"<Ztree> queryZtree =(queryZtree!=&&queryZtree.size()>0=
There is no need to write the dao layer, it is just a query. I will attach the ztree table fields below
I hope it can help everyone. This is the test code when I learn the ztree plug-in again, the annotated version of the ssh framework. I haven’t tried it in other frameworks, but after understanding how to use it, it should be fine. , I believe you are all much better than me. Not a master, just sharing. God, don’t squirt~~~~~~~~~~
The above is the detailed content of Use of zTree tree plug-in--Introduction to asynchronous loading method. For more information, please follow other related articles on the PHP Chinese website!