String createTreeJson(List<Resource> JSONArray rootArray = (resource.getParentid() == JSONObject rootObj = JSONObject createBranch(List<Resource> JSONObject currentObj = JSONArray childArray = (newNode.getParentid() != && newNode.getParentid().compareTo(currentNode.getId()) == 0 JSONObject childObj = (! currentObj.put("children" } //2、使用ztree实现树形数据简单无需用递归组装,简单方便
dep.dep_code, dep.dep_name, dep2.dep_code AS parent_Code, on dep.pdep_id = 主要返回的对应ztree的id、pId、name,其它属性可自定义,ztree会自动识别组装树形节点的数据; 还有就是实体bean中的属性除了定义数据库中的列属性之外,还应该把ztree中的节点属性也定义上
The above is the detailed content of How to display data in tree shape?. For more information, please follow other related articles on the PHP Chinese website!