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

     

            

              

            

            

            

          

              

          

                

  • 相关阅读:
    vc++编程之在程序中加入网址链接
    VC++编程之对话框贴图
    软考(软件设计师)注意事项(攻略)
    解决SQLite数据库中文乱码问题
    计算机专业中经典书籍(程序猿和大学生必读)
    VC++编程中为程序加入启动画面功能
    动态规划的详细解析(01背包问题)
    动态规划之深入灵魂的解读(非常好)
    UML类图详解
    团队冲刺——第四天
  • 原文地址:https://www.cnblogs.com/xujiating/p/7573251.html
Copyright © 2011-2022 走看看