dtree完成展开关闭功能

需求:当页面显示 展开 字段时,dtree结构展开,当页面显示 关闭 字段时,dtree结构关闭

如下图:
dtree完成展开关闭功能
dtree完成展开关闭功能
后台代码:

@RestController
@RequestMapping("dept")
public class DeptController {

    @Autowired
    private DeptService deptService;

    //展示树形结构
    @RequestMapping("buildLeftTree")
    public DataGridView buildLeftTree(){

      List<Dept>deptList=deptService.queryDeptList();

      List<DeptNode>treeNodeList = new ArrayList<>();
        for (Dept dept : deptList) {
            //spread是用于判断是 true : false
            // dept.getOpen()   open 是  是否展开字段
            Boolean spread= dept.getOpen() == 1 ? true : false;
             
             treeNodeList.add(new DeptNode(dept.getId(),dept.getPid(),dept.getTitle(),spread));
        }
        return new DataGridView(treeNodeList);
    }
@Data
@NoArgsConstructor
public class DeptNode {
    private Integer id;
    private Integer parentId;
    private String title;
    private Boolean spread;

    public DeptNode(Integer id, Integer parentId, String title,Boolean spread) {
        this.id = id;
        this.parentId = parentId;
        this.title = title;
        this.spread=spread;
    }
}
上一篇:斜线表头


下一篇:numpy学习线性回归, 并用matplotlib画动态图