Freemarker之封装easyUI的datagrid,旨在生成快捷方便的管理列表(一)
来源:互联网 发布:一个矩阵怎么计算 编辑:程序博客网 时间:2024/06/05 18:19
废话不多说,先上代码:
1、grid.ftl
这个就是封装的datagrid的通用组件
自定义输入参数的介绍:
controller:这个是我后台的地址(这里注意,我这里后台的地址命名是有规范的,默认添加、删除、更新、获取所有数据、根据id获取单个数据的地址分别为:add、delete、update、findById、findAll。前面的地址为/system/实体名)
title:总表格名
fields :这里注意了,这个是显示数据的必输字段,参考JSON,我自定义的格式为:fields:values,这样的格式,多条用逗号隔开。files是后台实体的字段名,values是字段名对应的列头
rownumbers=”true” :行号
singleSelect=”true” :是否能被选中
width=”1000px” :宽度
height=”500px”:高度
<#macro grid controller title fields rownumbers="true" singleSelect="true" width="1000px" height="500px"><!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Auto Height for Tabs - jQuery EasyUI Demo</title> <link rel="stylesheet" type="text/css" href="../lib/easyui/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="../lib/easyui/themes/icon.css"> <script type="text/javascript" src="../lib/easyui/jquery.min.js"></script> <script type="text/javascript" src="../lib/easyui/jquery.easyui.min.js"></script> <script type="text/javascript" src="../lib/easyui/locale/easyui-lang-zh_CN.js"></script> <script type="text/javascript" src="../lib/layer/layer.js"></script></head><body> <table id="table" class="easyui-datagrid" title="${title}" style="width:${width};height:${height}" data-options="rownumbers:${rownumbers},singleSelect:${singleSelect},url:'${controller}findAll',method:'get'"> <thead> <tr> <#list fields?split(",") as x> <#list x?split(":") as y> <#if (y_index ==0)> <th data-options="field:'${y}',width:200"> <#else> ${y}</th> </#if> </#list> </#list> </tr> </thead> </table></body></html></#macro>
2、调用公共组件
<#import "/common/grid.ftl" as userGrid><!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Auto Height for Tabs - jQuery EasyUI Demo</title></head><body> <@userGrid.grid controller="/system/user/" title="用户管理" width="1100px" height="500px" fields="id: ,c_username:用户名,c_phone:联系方式,n_age:年龄,n_sex:性别"> </@userGrid.grid></body></html>
在封装的时候还是遇到点问题,那就是在一个list中怎么把两组长度相同的数据放到同一个行里面。后面用下标判断解决了这个问题。
想看完整代码的可以去我的github上下载:github地址
阅读全文
0 0
- Freemarker之封装easyUI的datagrid,旨在生成快捷方便的管理列表(一)
- Freemarker之封装easyUI的datagrid,旨在生成快捷方便的管理列表(二)
- easyui.utils.js 自己封装的 使用easyui过程中方便操作和取值(一)
- easyui tab之自动生成带datagrid的Tab页
- easyUI组件datagrid的二次封装
- EASYUI之DataGrid的使用(java)
- easyui 列表datagrid初始化两次的问题
- 完整的easyui datagrid 动态生成列
- jquery easyui 学习之datagrid(一)
- 【EasyUI】初识之Datagrid(一)
- easyUI 的datagrid的自适应布局(一)
- UGUI(一)List列表的封装
- easyUI之DataGrid的分页要点
- easyui 之datagrid 的数据加载
- easyui datagrid 点击列表头排序出现错乱的原因
- easyUI的列表控件(datagrid)日期列不能正确显示Json格式数据的解决方法
- easyUI的列表控件(datagrid)日期列不能正确显示的解决方法
- easyui datagrid 的使用
- Android 自定义漂亮的圆形进度条
- Python+Eclipse+pyDev开发环境搭建
- Poj-1328 二维化一维 典型贪婪算法
- vmware10+centos6(64)搭建FTP服务
- String对象
- Freemarker之封装easyUI的datagrid,旨在生成快捷方便的管理列表(一)
- Gulp新手入门教程
- STM32F107——OTG模块之USB设备之虚拟串口移植(三)
- SQL基本语法知识(mysql)
- Kotlin学习笔记(2):run、apply、let、also、with的用法和区别
- mysql高可用之MHA
- 读前辈的大话设计模式(十)之建造者模式,抒自己的读后感
- 3DSlicer12:风格准则
- leetcode--141. Linked List Cycle&&142. Linked List Cycle II