jquery中EasyUI实现同步树
作者:bea
在JS中,将显示树的url地址写成control的地址即可. control: 代码如下: @RequestMapping(value = "/tree") public void tree(HttpServletRequest request, HttpServletResponse response) throws IOException { this.writeJson(response, bookService.getTree()); } dao:
在JS中,将显示树的url地址写成control的地址即可.
control:
代码如下:
@RequestMapping(value = "/tree")
public void tree(HttpServletRequest request, HttpServletResponse response) throws IOException {
this.writeJson(response, bookService.getTree());
}
dao:
代码如下:
/**
* 获取树
*/
@Override
public List<Tree> getTree(){
try {
List<Tree> trees = new ArrayList<Tree>();
List<TBookType> 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<TBookType> 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);
}
}
以上就是使用EasyUI实现同步树的全部核心代码了,希望大家能够喜欢。
有用 | 无用
control:
代码如下:
@RequestMapping(value = "/tree")
public void tree(HttpServletRequest request, HttpServletResponse response) throws IOException {
this.writeJson(response, bookService.getTree());
}
dao:
代码如下:
/**
* 获取树
*/
@Override
public List<Tree> getTree(){
try {
List<Tree> trees = new ArrayList<Tree>();
List<TBookType> 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<TBookType> 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);
}
}
以上就是使用EasyUI实现同步树的全部核心代码了,希望大家能够喜欢。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 了解Javascript的模块化开发
- JS实现的4种数字千位符格式化方法分享
- js实现图片漂浮效果的方法
- ECMAScript 5中的属性描述符详解
- JS+CSS实现可以凹陷显示选中单元格的方法
- JavaScript数组常用方法
- 使用npm发布Node.JS程序包教程
- js实现点击链接后窗口缩小并居中的方法
- 运行Node.js的IIS扩展iisnode安装配置笔记
- Javascript动画的实现原理浅析
- JavaScript页面模板库handlebars的简单用法
- EasyUI中实现form表单提交的示例分享
- EasyUI实现二级页面的内容勾选的方法
- EasyUI实现第二层弹出框的方法
- EasyUI,点击开启编辑框,并且编辑框获得焦点的方法
- 浅谈EasyUI中Treegrid节点的删除
- 浅谈EasyUI中编辑treegrid的方法
- EasyUI中combobox默认值注意事项
- jquery中EasyUI实现异步树