zoukankan      html  css  js  c++  java
  • jeecg中的树形控件demo

    1.comboTree控件

           1.页面方法:

                <t:comboTree url="jeecgFormDemoController.do?getComboTreeData" value="402880e447e99cf10147e9a03b320003" name="depid" id="depid" width="200"></t:comboTree>

      2.controller方法:

      

        @RequestMapping(params = "getComboTreeData")
        @ResponseBody
        public List<ComboTree> getComboTreeData(HttpServletRequest request, ComboTree comboTree) {
            CriteriaQuery cq = new CriteriaQuery(TSDepart.class);
              if (comboTree.getId() != null) {
                cq.eq("TSPDepart.id", comboTree.getId());
                            }
              if (comboTree.getId() == null) {
                cq.isNull("TSPDepart");
                            }
                  cq.add();
              List<TSDepart> demoList = systemService.getListByCriteriaQuery(cq, false);
              List<ComboTree> comboTrees = new ArrayList<ComboTree>();
              ComboTreeModel comboTreeModel = new ComboTreeModel("id", "departname", "TSDeparts");
                  comboTrees = systemService.ComboTree(demoList, comboTreeModel, null, false);
                      return comboTrees;
                              }

    2.ztree 控件

        1.页面方法:

            <t:selectZTree id="citySel" url="jeecgFormDemoController.do?getTreeData" windowWidth="400px"></t:selectZTree> 

        2.controller层方法

            

    @RequestMapping(params="getTreeData",method ={RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public AjaxJson getTreeData(TSDepart depatr,HttpServletResponse response,HttpServletRequest request ){
    AjaxJson j = new AjaxJson();
    try{
    List<TSDepart> depatrList = new ArrayList<TSDepart>();
    StringBuffer hql = new StringBuffer(" from TSDepart t");
    //hql.append(" and (parent.id is null or parent.id='')");
    depatrList = this.systemService.findHql(hql.toString());
    List<Map<String,Object>> dataList = new ArrayList<Map<String,Object>>();
    Map<String,Object> map = null;
    for (TSDepart tsdepart : depatrList) {
    String sqls = null;
    Object[] paramss = null;
    map = new HashMap<String,Object>();
    map.put("id", tsdepart.getId());
    map.put("name", tsdepart.getDepartname());
    if (tsdepart.getTSPDepart() != null) {
    map.put("pId", tsdepart.getTSPDepart().getId());
    map.put("open",false);
    }else {
    map.put("pId", "1");
    map.put("open",false);
    }
    sqls = "select count(1) from t_s_depart t where t.parentdepartid = ?";
    paramss = new Object[]{tsdepart.getId()};
    long counts = this.systemService.getCountForJdbcParam(sqls, paramss);
    if(counts>0){
    dataList.add(map);
    }else{
    TSDepart de = this.systemService.get(TSDepart.class, tsdepart.getId());
    if (de != null) {
    map.put("id", de.getId());
    map.put("name", de.getDepartname());
    if(tsdepart.getTSPDepart()!=null){
    map.put("pId", tsdepart.getTSPDepart().getId());
    map.put("open",false);
    }else{
    map.put("pId", "1");
    map.put("open",false);
    }
    dataList.add(map);
    }else{
    map.put("open",false);
    dataList.add(map);
    }
    }
    }
    j.setObj(dataList);
    }catch(Exception e){
    e.printStackTrace();
    }
    return j;
    }

     

            

              

            

            

            

          

              

          

                

  • 相关阅读:
    IntelliJ IDEA设置JVM运行参数
    IntelliJ IDEA 乱码解决方案 (项目代码、控制台等)
    188.索引与视图
    187.数据库操作
    186.元素
    185.流程设计
    184.数据操纵语言DML
    改变linux shell前景色和背景色
    Centos文本方式安装情况下lvm分区的创建
    深入理解计算机系统第二版习题解答CSAPP 2.20
  • 原文地址:https://www.cnblogs.com/xujiating/p/7573251.html
Copyright © 2011-2022 走看看