JEECG树(TreeGrid)字段的扩展
转载: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)字段的扩展的更多相关文章
- Sharepoint 2013列表视图和字段权限扩展插件(免费下载)!
记得2014年春节期间,有博客园的网友通过QQ向我咨询Sharepoint 2013列表视图和字段权限扩展,因为之前他看到我博客介绍Sharepoint 2010列表视图和字段的权限控制扩展使用,问有 ...
- C#学习-属性是对字段的扩展
属性是对字段的扩展. 根据面向对象语言的封装思想,字段最好设为private,因为这样可以防止客户端直接对字段进行篡改,从而保证了内部成员的完整性. 于是为了访问类中的私有字段,C#提供了属性这种机制 ...
- bzoj2325 [ZJOI2011]道馆之战 树链剖分+DP+类线段树最大字段和
题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=2325 题解 可以参考线段树动态维护最大子段和的做法. 对于线段树上每个节点 \(o\),维护 ...
- POJ1849Two[DP|树的直径](扩展HDU4003待办)
Two Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1390 Accepted: 701 Description Th ...
- 学习笔记: Expression表达式目录树详解和扩展封装
1. 表达式链接扩展封装,ORM常用 And Or /// <summary> /// 表达式访问者 /// </summary> public class Expressi ...
- 数据网格和树-EasyUI Datagrid 数据网格、EasyUI Propertygrid 属性网格、EasyUI Tree 树、EasyUI Treegrid 树形网格
EasyUI Datagrid 数据网格 扩展自 $.fn.panel.defaults.通过 $.fn.datagrid.defaults 重写默认的 defaults. 数据网格(datagrid ...
- 使用BAPI_ACC_DOCUMENT_POST,创建会计凭证,用BADI扩展字段(转)
业务需求:和银行做一个接口,要通过银行流水产生会计凭证,会计凭证的事务码是F-02,查到了BAPI方法BAPI_ACC_DOCUMENT_POST.昨天测试发现,有一些参数在BAPI_ACC_DOCU ...
- 纸壳CMS现已支持自定义扩展字段
简介 纸壳CMS是开源免费的可视化内容管理系统. GitHub https://github.com/SeriaWei/ZKEACMS 自定义字段 纸壳CMS现已支持自定义字段,在不修改代码的情况下, ...
- 第二百二十八节,jQuery EasyUI,TreeGrid(树形表格)组件
jQuery EasyUI,TreeGrid(树形表格)组件 学习要点: 1.加载方式 2.属性列表 3.事件列表 4.方法列表 本节课重点了解 EasyUI 中 TreeGrid(树形表格)组件的使 ...
随机推荐
- Linux环境下Eclipse对C++新特性的支持设置
Linux环境下Eclipse对C++新特性的支持设置 今天写一个简单的关于C11中的array容器的测试程序如下, #include <iostream> #include &l ...
- Pandas Series数据结构基本操作
>>> import pandas >>> import numpy as np >>> from pandas import Series,Da ...
- 部署项目问题(maven打包jar不对应,导致启动时一直找不到某个类)
项目是springboot+maven 打包用maven的插件package 下面是打包后的目录结构 project-1.0 和project-1.0.tar.gz是一样的 区别就是一个是压缩包 ...
- MVC中的自定义标签分页控件,仅供大家学习!!
public static HtmlString ShowPageNavigate(this HtmlHelper htmlHelper, int currentPage, int pageSize, ...
- Activity向Fragment传值
发送数据 //Activity传值,通过Bundle Bundle bundle = new Bundle(); bundle.putString("MainActivity", ...
- nginx信号及平滑升级
1.nginx信号 nginx进程处理命令: kill -signals PID PID即nginx进程ID signals的参数解释如下所示: TERM,INT快速关闭进程 QUIT优雅的关闭,如果 ...
- 单实例安装elastic和启动报错解决
下载 先到官网https://www.elastic.co/cn/downloads/past-releases/elasticsearch-5-5-2下载,我安装的是5.5.2的版本,其他版本直接访 ...
- rest framework之路由组件
一.路由组件的使用 1.使用实例 在视图中继承GenericViewSet类来完成功能时,需要自己对路由的写法有所改变,需要在as_view中传入actions字典参数: re_path('books ...
- js 实现 间隙滚动效果
代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3. ...
- loj2573[TJOI2018]数字计算
题意:操作1:x=x*m,输出x%mod.2.x/=map[m].m即第m次操作,保证该次操作为1操作,并且每个操作最多只会被删一次.q<=1e5. 线段树维护操作信息的乘积,删除把对应位置的权 ...