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;
    }

     

            

              

            

            

            

          

              

          

                

  • 相关阅读:
    一、Java语言基础(2)_类型和运算——基本数据类型转换
    一、Java语言基础(2)_类型和运算——数据类型和分类
    一、Java语言基础(2)_类型和运算——字面量和常量
    一、Java语言基础(1)_走进java——基本语法
    接口测试彻底弄懂Session、Cookie、Token的区别及联系hold住面试官--hold住了开3万,hold不住开3K!
    待过猫厂、狗厂、鹅厂、猪厂的10年测试码农告诉你-测试计划与测试方案的区别?
    2020非常全的接口测试面试题及参考答案-软件测试工程师没有碰到算我输!
    2020非常全的软件测试linux常用命令全集,linux面试题及参考答案
    jmeter实现接口关联的两种方式:正则表达式提取器和json提取器看这篇就够了
    通过pycharm使用git和github的步骤(图文详解)
  • 原文地址:https://www.cnblogs.com/xujiating/p/7573251.html
Copyright © 2011-2022 走看看