转载:https://blog.csdn.net/huangzirong822/article/details/38400817

之前使用jeecg集成框架做过一个项目

这里说说框架中树(tree)字段的扩展,在jeecg集成框架中,树列字段默认只能显示两列,如下图所示:

通常情况下前后台代码格式如下所示

前台代码获取(部分)

<t:datagrid name="departList" title="部门列表" actionUrl="departController.do?departgrid" treegrid="true" idField="departid" pagination="false" onClick="queryUsersByRowData">
<t:dgCol title="编号" field="id" treefield="id" hidden="false"></t:dgCol>
<t:dgCol title="部门名称" field="departname" treefield="text" ></t:dgCol>
<t:dgCol title="职能描述" field="description" treefield="src"></t:dgCol>
<t:dgCol title="操作" field="opt"></t:dgCol>
<t:dgDelOpt url="departController.do?del&id={id}" title="删除"></t:dgDelOpt>
<t:dgFunOpt funname="queryUsersByDepart(id)" title="查看成员"></t:dgFunOpt>
</t:datagrid> 后台代码(部分) /**
* 部门列表,树形展示
* @param request
* @param response
* @param treegrid
* @return
*/
@RequestMapping(params = "departgrid")
@ResponseBody
public List<TreeGrid> departgrid(TSDepart tSDepart,HttpServletRequest request, HttpServletResponse response, TreeGrid treegrid) {
CriteriaQuery cq = new CriteriaQuery(TSDepart.class);
if("yes".equals(request.getParameter("isSearch"))){
treegrid.setId(null);
tSDepart.setId(null);
}
if(null != tSDepart.getDepartname()){
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, tSDepart);
}
if (treegrid.getId() != null) {
cq.eq("TSPDepart.id", Integer.parseInt(treegrid.getId()));
}
if (treegrid.getId() == null) {
cq.isNull("TSPDepart.id");
}
cq.add();
List<TreeGrid> departList =null;
departList = systemService.getListByCriteriaQuery(cq, false);
if(departList.size() == && tSDepart.getDepartname() != null){
cq = new CriteriaQuery(TSDepart.class);
TSDepart parDepart = new TSDepart();
tSDepart.setTSPDepart(parDepart);
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, tSDepart);
departList = systemService.getListByCriteriaQuery(cq, false);
}
List<TreeGrid> treeGrids = new ArrayList<TreeGrid>();
TreeGridModel treeGridModel = new TreeGridModel();
treeGridModel.setTextField("departname");
treeGridModel.setParentText("TSPDepart_departname");
treeGridModel.setParentId("TSPDepart_id");
treeGridModel.setSrc("description");
treeGridModel.setIdField("id");
treeGridModel.setChildList("TSDeparts");
treeGrids = systemService.treegrid(departList, treeGridModel);
return treeGrids;
} 以上是没有是没有扩展树字段的实例,以下是扩展的实例
!扩展方法
其实扩展方法很简单,因为 作者已经帮我们留了扩展的方法了。捕捉树列表响应的数据如下(部分响应数据): [
{
"operations": null,
"note": null,
"order": null,
"src": "",
"parentId": "",
"parentText": "中联总部",
"id": "",
"state": "closed",
"attributes": null,
"text": "中联总部",
"code": null
},
{
"operations": null,
"note": null,
"order": null,
"src": "",
"parentId": "",
"parentText": "混凝土机械国际管理公司",
"id": "",
"state": "closed",
"attributes": null,
"text": "混凝土机械国际管理公司",
"code": null
},
{
"operations": null,
"note": null,
"order": null,
"src": "",
"parentId": "",
"parentText": "工程起重机公司",
"id": "",
"state": "closed",
"attributes": null,
"text": "工程起重机公司",
"code": null
},
{
"operations": null,
"note": null,
"order": null,
"src": "",
"parentId": "",
"parentText": "建筑起重机公司",
"id": "",
"state": "closed",
"attributes": null,
"text": "建筑起重机公司",
"code": null
}
] 以上数据可以看出在每条返回的数据中存在一个attribute字段,但都是空值。其实这个就是可以扩展的字段attribute是一个HashMap 即扩展树字段的方法原理就是后台添加attribute并把需要在前台显示的值存进去,前台取attribute的值。代码如下 后台代码(因为没有扩展上面机构tree代码,我挑选了其他树扩展的代码) Map<String , String> map;
for (int i = ; i < treeGrids.size(); i++) {
map = new HashMap<String, String>();
map.put("description", assetDepreciationList.get(i).getDescription());
treeGrids.get(i).setAttributes(map);
}
把需要扩展显示的字段put进去,上面我增加了一个显示字段,如果有多个同样put多个进去。 前台jsp代码 <t:datagrid name="assetDepreciationList" title="折旧类型管理" actionUrl="assetDepreciationController.do?assetDepreciationGrid" idField="id" treegrid="true" pagination="false" fit="true">
<t:dgCol title="编号" field="id" treefield="id" hidden="false"></t:dgCol>
<t:dgCol title="折旧计算方法" field="depreciationWay" treefield="text"></t:dgCol>
<t:dgCol title="折算周期" field="depreciationCycle" treefield="src"></t:dgCol>
<t:dgCol title="方法描述" field="attributes.description" treefield="attributes.description" extendParams="formatter:function(value, rec, index){return rec.attributes.description};" width=""></t:dgCol>
<t:dgCol title="操作" field="opt" width=""></t:dgCol>
<t:dgDelOpt title="删除" url="assetDepreciationController.do?del&id={id}"/>
<t:dgToolBar title="录入" icon="icon-add" url="assetDepreciationController.do?addorupdate" funname="add"></t:dgToolBar>
<t:dgToolBar title="编辑" icon="icon-edit" url="assetDepreciationController.do?addorupdate" funname="update"></t:dgToolBar>
<t:dgToolBar title="查看" icon="icon-search" url="assetDepreciationController.do?addorupdate" funname="detail"></t:dgToolBar>
</t:datagrid> 方法描述即为扩展的显示列(写法如下)
写法一 <t:dgCol title="方法描述" field="attributes.description" treefield="attributes.description" extendParams="formatter:function(value, rec, index){return rec.attributes.description};" width=""></t:dgCol> 或者是将js方法写出来
写法二 <t:dgCol title="方法描述" field="attributes.description" treefield="attributes.description" extendParams="formatter:getDescription;" width=""></t:dgCol>
function getDescription(value, rec, index) {
return rec.attributes.descripition;
}
以上就是jeecg中树的列显示字段扩展,如果有多个需要扩展就根据以上格式编写多个即可。 ---------------------
版权声明:本文为CSDN博主「Zero-荣子」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/huangzirong822/article/details/38400817

JEECG树(TreeGrid)字段的扩展的更多相关文章

  1. Sharepoint 2013列表视图和字段权限扩展插件(免费下载)!

    记得2014年春节期间,有博客园的网友通过QQ向我咨询Sharepoint 2013列表视图和字段权限扩展,因为之前他看到我博客介绍Sharepoint 2010列表视图和字段的权限控制扩展使用,问有 ...

  2. C#学习-属性是对字段的扩展

    属性是对字段的扩展. 根据面向对象语言的封装思想,字段最好设为private,因为这样可以防止客户端直接对字段进行篡改,从而保证了内部成员的完整性. 于是为了访问类中的私有字段,C#提供了属性这种机制 ...

  3. bzoj2325 [ZJOI2011]道馆之战 树链剖分+DP+类线段树最大字段和

    题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=2325 题解 可以参考线段树动态维护最大子段和的做法. 对于线段树上每个节点 \(o\),维护 ...

  4. POJ1849Two[DP|树的直径](扩展HDU4003待办)

    Two Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1390   Accepted: 701 Description Th ...

  5. 学习笔记: Expression表达式目录树详解和扩展封装

    1. 表达式链接扩展封装,ORM常用 And  Or /// <summary> /// 表达式访问者 /// </summary> public class Expressi ...

  6. 数据网格和树-EasyUI Datagrid 数据网格、EasyUI Propertygrid 属性网格、EasyUI Tree 树、EasyUI Treegrid 树形网格

    EasyUI Datagrid 数据网格 扩展自 $.fn.panel.defaults.通过 $.fn.datagrid.defaults 重写默认的 defaults. 数据网格(datagrid ...

  7. 使用BAPI_ACC_DOCUMENT_POST,创建会计凭证,用BADI扩展字段(转)

    业务需求:和银行做一个接口,要通过银行流水产生会计凭证,会计凭证的事务码是F-02,查到了BAPI方法BAPI_ACC_DOCUMENT_POST.昨天测试发现,有一些参数在BAPI_ACC_DOCU ...

  8. 纸壳CMS现已支持自定义扩展字段

    简介 纸壳CMS是开源免费的可视化内容管理系统. GitHub https://github.com/SeriaWei/ZKEACMS 自定义字段 纸壳CMS现已支持自定义字段,在不修改代码的情况下, ...

  9. 第二百二十八节,jQuery EasyUI,TreeGrid(树形表格)组件

    jQuery EasyUI,TreeGrid(树形表格)组件 学习要点: 1.加载方式 2.属性列表 3.事件列表 4.方法列表 本节课重点了解 EasyUI 中 TreeGrid(树形表格)组件的使 ...

随机推荐

  1. Oracle中使用REGEXP_SUBSTR,regexp_replace,wm_concat函数

    REGEXP_SUBSTR函数格式如下: function REGEXP_SUBSTR(String, pattern, position, occurrence, modifier)__srcstr ...

  2. 如何理解c和c++的复杂类型声明

    曾经碰到过让你迷惑不解.类似于int * (* (*fp1) (int) ) [10];这样的变量声明吗?本文将由易到难,一步一步教会你如何理解这种复杂的C/C++声明. 我们将从每天都能碰到的较简单 ...

  3. MySQL高级学习笔记(一):mysql简介、mysq linux版的安装(mysql 5.5)

    文章目录 MySQL简介 概述 mysql高手是怎样炼成的 mysq linux版的安装(mysql 5.5) 下载地址 拷贝&解压缩 检查工作 检查当前系统是否安装过mysql 检查/tmp ...

  4. camunda授权的一些简单操作

    /** * 授权操作 */public class ZccAuthorizationService { AuthorizationService authorizationService; @Befo ...

  5. Linux(二)—— Linux配置及指令

    目录 Linux配置及指令 一.linux中常用软件的安装 二.主机名和网络 1.修改主机名 2.设置网络 三.关闭防火墙 1.检查防火墙是否开启 2.清除策略 3.永久关闭第一个防火墙 4.关闭第二 ...

  6. 【Linux】- 同步网络时间

    转自:Linux同步网络时间 Linux服务器运行久时,系统时间就会存在一定的误差,一般情况下可以使用date命令进行时间设置,但在做数据库集群分片等操作时对多台机器的时间差是有要求的,此时就需要使用 ...

  7. redis 入门之哈希

    hset 将哈希表 hash 中域 field 的值设置为 value .如果给定的哈希表并不存在, 那么一个新的哈希表将被创建并执行 HSET 操作.如果域 field 已经存在于哈希表中, 那么它 ...

  8. Python值正则表达式(RE)

    要想在Python中使用正则表达式,首先要引入模块: import re . 匹配任意一个 +   匹配至少一个 * 匹配0个至多个 ? 1个或0个(可有可无) - 表范围 \ 转义 ^   在首 $ ...

  9. OOP三大特性及几大设计原则

    封装: 1.隐藏实现细节:2.恰当地公开接口:3.将接口和实现分开,增强可维护性:(实现细节改变时,使用该类的客户端程序不需要改变) 继承: 1.描述联结类的层次模型;2.通过抽象,表达共性,实现类的 ...

  10. git暂存区

    在使用git开发时,有三个概念需要知道,工作区,暂存区和版本库.工作区就是直接进行操作的地方,版本库是要将修改提交的地方,那么暂存区是干什么的呢?下面将对暂存区深入研究. 一.修改后能直接提交吗? 在 ...