1 首先在前端应用树树控件

<div class="fui-left">
<div role="head" title="地区选择"></div>
<div role="body">
<div id="key" class="mini-textbox hidden" style="width: 150px;" onenter="onKeyEnter" />
<div class="mini-button hidden" style="width: 50px;" onclick="search()">查询</div>
<div id="tree1" class="mini-tree" showFolderCheckBox="true" action="treeModel" canCheckParent="true"></div>
</div>
</div>

2 在后台要有一个变量与之对应

private TreeModel treeModel = null;

3 这个变量的get方法来获得数据

public TreeModel getTreeModel() {
if (treeModel == null) {
treeModel = new TreeModel()
{
private static final long serialVersionUID = 1L; @Override
public List<TreeNode> fetch(TreeNode pNode) {
List<Record> tmplist;
String guid = "";
if (pNode != null)
guid = pNode.getId(); // 根节点
if (StringUtil.isBlank(guid)) { tmplist = service.findList(
"select CityName,CityCode from HuiYuan_City where right(CityCode,4)='0000' order by CityCode ",
Record.class); }
else {
guid = Functions.TrimEnd(guid, "0");
String sql = "";
if (guid.length() == 2) {
sql = "select CityName,CityCode from HuiYuan_City where citycode like '" + guid
+ "%' and right(CityCode,2)='00' and right(CityCode,4)<>'0000' order by CityCode";
}
else if (guid.length() == 4) {
sql = "select CityName,CityCode from HuiYuan_City where citycode like '" + guid
+ "%' and right(CityCode,2)<>'00' order by CityCode";
}
tmplist = service.findList(sql, Record.class);
} List<TreeNode> treeNodes = new ArrayList<TreeNode>(); //修改在省级子节点中出现"所有地区"节点的问题 by dingbq 2016-8-29
if(StringUtil.isBlank(guid)){
TreeNode node1 = new TreeNode();
node1.setId("999");
node1.setText("所有地区");
node1.setLeaf(false);
node1.setExpanded(true);
treeNodes.add(node1);
} for (Record record : tmplist) {
TreeNode node = new TreeNode();
node.setId(record.getStr("CityCode"));
node.setText(record.getStr("CityName"));
String code = node.getId();
if(StringUtil.isBlank(guid)){
node.setPid("999");
}
if (code.endsWith("00"))
node.setLeaf(false);
else
node.setLeaf(true);
treeNodes.add(node);
}
return treeNodes;
} }; }
return treeModel;
}

F9 开发之左树右表中的左树的更多相关文章

  1. eas左树右表基础资料界面引用为左树右表F7的简单方法

    age:   /** * 加载配件F7(左树右表) * @param F7Filed           要加载的F7控件 * @param ctx               界面上下文 * @单据 ...

  2. java小工具,使用Swing展示左树右表结构

    代码直接上: 入口类 import java.io.File; import java.util.ArrayList; import java.util.List; import org.json.J ...

  3. SQL 左外连接查询 将右表中的多行变为左表的一列或多列

    示例: --行列互转 /**************************************************************************************** ...

  4. laravel利用subquery使左连接查询右表数据唯一查询

    如:表a,连接表b,b中有多条符合查询的记录 1.建立需要的子查询 $sub = DB::table('b')->select(['aid'])->selectRaw('max(id) a ...

  5. sql server中的左连接与右连接的简便写法

    左连接 *=(左表中的数据全部显示出来,右表中没有相关联的数据显示null) select Users.*,Department.name as DepartmentName from Users,D ...

  6. mysql左连接右连接(查询两张表不同的数据)

    有两张表:一张A表he一张B表 left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 :right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录: ...

  7. mysql中的左连接右连接内连接

    一. 初始化SQL语句 /*join 建表语句*/ drop database if exists test; create database test; use test; /* 左表t1*/ dr ...

  8. Python进阶----多表查询(内连,左连,右连), 子查询(in,带比较运算符)

    Python进阶----多表查询(内连,左连,右连), 子查询(in,带比较运算符) 一丶多表查询     多表连接查询的应用场景: ​         连接是关系数据库模型的主要特点,也是区别于其他 ...

  9. c++中的左值与右值

    左值(lvalue)和右值(rvalue)是 c/c++ 中一个比较晦涩基础的概念,不少写了很久c/c++的人甚至没有听过这个名字,但这个概念到了 c++11 后却变得十分重要,它们是理解 move/ ...

随机推荐

  1. ASP.NET MVC3开发-数据库篇之CodeFisrt开发(一)

    本文讲述了在ASP.NET MVC3开发中M层使用Code Fisrt如何进行开发,由于作者对ASP.NET MVC3的学习不是很深,所以写的都是些基本的内容(写的如有不正确的地方请评论指正),适合初 ...

  2. 【NET】Winform用户控件的初步封装之列表页控件

    public abstract partial class TListPager<TEntity, TRepository, TSqlStrConstruct> : UserControl ...

  3. AspxTreeList获取选中项的值

    在csdn上了发了次帖子,没人回复,只有自己结贴了.http://bbs.csdn.net/topics/390706314?page=1#post-396723432 //通过选中的节点获取用户ID ...

  4. DRP项目总结

    DRP项目在6号就已经完工了,总共花费了一个半月的时间,从对java的懵懵懂懂,到现在的略微熟悉,对整个java web开发的认知,清晰了很多.涉及到的web项目开发的必备知识,也都有一次得到锻炼和提 ...

  5. POJ 1873 The Fortified Forest

    题意:是有n棵树,每棵的坐标,价值和长度已知,要砍掉若干根,用他们围住其他树,问损失价值最小的情况下又要长度足够围住其他树,砍掉哪些树.. 思路:先求要砍掉的哪些树,在求剩下的树求凸包,在判是否可行. ...

  6. Centos6.3不能使用yum install安装gcc编辑器解决办法

    mv /var/lib/rpm/__db* /tmp rpm --rebuilddb yum clean all

  7. 自己动手写spring容器(2)

    上篇我们自己写了一个很简单的spring容器,该容器只是做了简单的bean的实例化,并没有spring的核心之一的IOC(依赖注入),也叫做控制反转,这里我就不讲这个的具体含义,不知道的园友可以自行百 ...

  8. 一步一步深入spring(2)-三种方式来实例化bean

    在一步一步深入spring(1)--搭建和测试spring的开发环境中提到了一种实例化bean的方式,也是最基本的使用构造器实例化bean 1.使用构造器实例化bean:这是最简单的方式,Spring ...

  9. 约瑟夫问题的java实现

    约瑟夫问题,又称丢手帕问题.试着实现了一下,实现逻辑简单,没有复杂的算法,适合新手参考. //参数step指步进值,步进到几则出列 //参数count指共有几个人 public static int ...

  10. OC之方法的声明实现和调用

    1. 类是来描述一群具有相同特征和行为的事物的. 类还有行为. 类的声明 @interface 类名 : NSObject { 属性. } 方法的声明 @end 类的实现. @implementati ...