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

     

            

              

            

            

            

          

              

          

                

  • 相关阅读:
    谈谈分布式事务之一:SOA需要怎样的事务控制方式
    asp.net创建自定义排序用户界面
    在ASP.NET 2.0中操作数据:在GridView的页脚中显示统计信息
    Url重写技术的运用(转)
    ASP.NET 对 SqlDataSource 控件使用参数
    正则表达式分支条件与分组
    向DWR传递参数和返回参数(转)
    一位软件工程师的6年总结(转)
    ASP.NET 2.0数据教程之二十六::排序自定义分页数据
    Table控件使用示例
  • 原文地址:https://www.cnblogs.com/xujiating/p/7573251.html
Copyright © 2011-2022 走看看