jquery中EasyUI实现同步树_jquery
程序员文章站
2024-04-06 08:24:55
...
在JS中,将显示树的url地址写成control的地址即可.
@RequestMapping(value = "/tree")
public void tree(HttpServletRequest request, HttpServletResponse response) throws IOException {
this.writeJson(response, bookService.getTree());
}
/**
* 获取树
*/
@Override
public List getTree(){
try {
List trees = new ArrayList();
List root = this.search(0);
if(root != null && root.size() > 0){
for(TBookType tb : root){
Tree rootnode = this.getNode(tb);
rootnode.setState("open");
trees.add(rootnode);
}
}
return trees;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 递归
*/
private Tree getNode(TBookType node){
if(node == null){
return null;
}
try {
Tree treenode = new Tree();
treenode.setId(String.valueOf(node.getId()));
treenode.setText(node.getName());
treenode.setPid(String.valueOf(node.getPid()));
List children = this.search(node.getId());
if(children != null && children.size() > 0){
treenode.setState("closed");
for(TBookType child : children){
Tree childnode = this.getNode(child);
if(childnode != null){
treenode.getChildren().add(childnode);//递归
}
}
}
return treenode;
} catch (Exception e) {
throw new BusinessException("获取数据出错!", e);
}
}
control:
复制代码 代码如下:
@RequestMapping(value = "/tree")
public void tree(HttpServletRequest request, HttpServletResponse response) throws IOException {
this.writeJson(response, bookService.getTree());
}
dao:
复制代码 代码如下:
/**
* 获取树
*/
@Override
public List
try {
List
List
if(root != null && root.size() > 0){
for(TBookType tb : root){
Tree rootnode = this.getNode(tb);
rootnode.setState("open");
trees.add(rootnode);
}
}
return trees;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 递归
*/
private Tree getNode(TBookType node){
if(node == null){
return null;
}
try {
Tree treenode = new Tree();
treenode.setId(String.valueOf(node.getId()));
treenode.setText(node.getName());
treenode.setPid(String.valueOf(node.getPid()));
List
if(children != null && children.size() > 0){
treenode.setState("closed");
for(TBookType child : children){
Tree childnode = this.getNode(child);
if(childnode != null){
treenode.getChildren().add(childnode);//递归
}
}
}
return treenode;
} catch (Exception e) {
throw new BusinessException("获取数据出错!", e);
}
}
以上就是使用EasyUI实现同步树的全部核心代码了,希望大家能够喜欢。
上一篇: yii 查询问题
下一篇: Google搜索引擎排名技巧
推荐阅读
-
jquery中EasyUI实现同步树_jquery
-
jquery中EasyUI实现异步树_jquery
-
EasyUI中combobox默认值注意事项_jquery
-
ASP.NET中实现jQuery Validation-Engine的Ajax验证实现代码
-
基于asp.net+ easyui框架,js提交图片,实现先上传图片再提交表单 博客分类: 【EasyUI】 asp.netjavascript框架jquery
-
java easyui 树型结构 查询 封装 博客分类: jQuery easyuijava javaeasyui树型结构查询封装
-
ASP.NET中实现jQuery Validation-Engine的Ajax验证实现代码
-
ASP.NET中实现jQuery Validation-Engine的Ajax验证
-
jquery中如何获得服务器控件实现思路
-
ASP.NET中实现jQuery Validation-Engine的Ajax验证