table形式的列表页面显示
(该案例在
项目中的reserve_bchmc.html,其对应的后台在CountBean中)
先看一下效果图:

该列表页面并不是用easyUI中的datagrid实现的,而是用table实现页面显示的
原理:页面上的数据每一行数据存放在一个对象里面,与户主相关的数据都是从数据库取的,然后将查询出来的数据放在一个list集合中,查询出几条数据出来list集合中就有几个实体对象,对于后面进行计算的四条数据则是通过查出来的数据计算得到并new一个新的实体对象保存在其中,然后将该对象追加到list集合中,后台统一将该list传到前台,前台通过遍历,按顺序添加到table表中,前面户主数据都是相同的字段,因此只需要调用同一个该行添加操作,而后四条数据则根据对象在list集合中的位置就行一一添加,list集合位置用下标确定。
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="../skin/easyui/icon.css">
<link rel="stylesheet" type="text/css" href="../skin/easyui/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../skin/css/form.css">
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../js/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/DateUtil.js"></script>
<script type="text/javascript" src="../js/JsonUtil.js"></script>
<script type="text/javascript" src="../js/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" src="../js/validator.js"></script>
<style type="text/css">
.datagrid-toolbar {border-bottom: 1px #95B8E7 solid;}
</style>
</head>
<body class="easyui-layout">
<div data-options="region:'center',title:'补偿花名册'">
<!---表格列表-->
<div title="">
<div class="datagrid-toolbar" style="padding: 5px;">
<div style="float: left">
<a href="#" class="easyui-linkbutton" onClick="back()" data-options="iconCls:'icon-back'">返回</a>
<a onclick="toAdd('')" class="easyui-linkbutton" data-options="iconCls:'icon-add'">新建</a>
<a class="easyui-linkbutton" class="btnSave" onClick="save()" data-options="iconCls:'icon-save'">保存</a>
</div>
<div style="float: right">
<a onclick="toExport()" class="easyui-linkbutton" data-options="iconCls:'icon-export'">导出</a>
</div>
<!---消除浮动--->
<div style="clear: both"></div>
</div>
</div> <div data-options="region:'center'">
<form id="form">
<table class="TBLForm" cellpadding="5" width="100%">
<thead>
<tr>
<td rowspan="2" colspan="2" align="center" height="30px">户名</td>
<td rowspan="2" align="center" height="30px">面积</td>
<td rowspan="2" align="center" height="30px">安置补助费</td>
<td colspan="2" align="center" height="30px">土地补偿费</td>
<td rowspan="2" align="center" height="30px">青苗费</td>
<td rowspan="2" align="center" height="30px">附作物费用</td>
<td rowspan="2" align="center" height="30px">总额</td>
<td rowspan="2" align="center" height="30px">身份证号码</td>
<td rowspan="2" align="center" height="30px">备 注</td>
<td rowspan="2" align="center" height="30px">操 作</td>
</tr>
<tr>
<td align="center" height="30px">个人(70%)</td>
<td align="center" height="30px" style="border:1px solid #95B8E7">集体(30%)</td>
</tr>
</thead>
<tbody></tbody>
</table>
</form>
</div>
</div>
</body>
JavaScript:
<script type="text/javascript">
var pid=getQueryStr("id");
var pageNum=getQueryStr("pageNum");
var flag;
$(function(){
loadTable();
})
function getJsonParam(){
var json={pid:pid};
return json2str(json);
}
//初始化表格
function loadTable(){
var data = getJsonData("../getTableList.hebe",getJsonParam());
var arr = [];
//len代表相同字段的数据数组下标
var len = data.length - 4;
$.each(data, function(i, row) {
//遍历数组下标
//if中是遍历最后四条不同的记录数据
if(i >= len) {
if(i==len) {
arr.push('<tr><td rowspan="3" align="center" height="30px">村集体</td>');
arr.push('<td align="center" height="30px">集体土地</td>');
arr.push('<td align="center" height="30px" ondblclick="updatemj(this)"><input class="easyui-numberbox" id="jttdmj" precision="3" value="'+row.mj+'" style="width: 80px"/></td>');
arr.push('<td align="center" height="30px">' + row.azbcf + '</td>');
arr.push('<td align="center" height="30px">' + row.grtdbcf + '</td>');
arr.push('<td align="center" height="30px">/</td>');
arr.push('<td align="center" height="30px">' + row.qmf_bz + '</td>');
arr.push('<td align="center" height="30px" ondblclick="updatefz(this)"><input class="easyui-numberbox" id="jttdfzwf" value="' + row.jttdfzwf + '" style="width: 80px"/></td>');
arr.push('<td align="center" height="30px">' + row.ze + '</td>');
arr.push('<td align="center" height="30px">' + row.sfzhm + '</td>');
arr.push('<td align="center" height="30px">' + row.remark + '</td>');
arr.push('<td align="center" height="30px"></td></tr>');
}
if(i==len+1) {
arr.push('<td align="center" height="30px">30%部分</td>');
arr.push('<td align="center" height="30px">' + row.mj + '</td>');
arr.push('<td align="center" height="30px">/</td>');
arr.push('<td align="center" height="30px">/</td>');
arr.push('<td align="center" height="30px">' + row.jttdbcf + '</td>');
arr.push('<td align="center" height="30px">/</td>');
arr.push('<td align="center" height="30px">/</td>');
arr.push('<td align="center" height="30px">' + row.ze + '</td>');
arr.push('<td align="center" height="30px"></td>');
arr.push('<td align="center" height="30px"></td>');
arr.push('<td align="center" height="30px"></td></tr>'); }
if(i==len+2) {
arr.push('<td align="center" height="30px">小计</td>');
arr.push('<td align="center" height="30px">' + row.mj + '</td>');
arr.push('<td align="center" height="30px">' + row.azbcf + '</td>');
arr.push('<td align="center" height="30px">' + row.grtdbcf + '</td>');
arr.push('<td align="center" height="30px">' + row.jttdbcf + '</td>');
arr.push('<td align="center" height="30px">' + row.qmf_bz + '</td>');
arr.push('<td align="center" height="30px">' + row.dsfzwf + '</td>');
arr.push('<td align="center" height="30px">' + row.ze + '</td>');
arr.push('<td align="center" height="30px">' + row.sfzhm + '</td>');
arr.push('<td align="center" height="30px">' + row.remark + '</td>');
arr.push('<td align="center" height="30px"></td></tr>');
}
if(i==len+3){
arr.push('<td colspan="2" align="center" height="30px">合计</td>');
arr.push('<td align="center" height="30px">' + row.mj + '</td>');
arr.push('<td align="center" height="30px">' + row.azbcf + '</td>');
arr.push('<td align="center" height="30px">' + row.grtdbcf + '</td>');
arr.push('<td align="center" height="30px">' + row.jttdbcf + '</td>');
arr.push('<td align="center" height="30px">' + row.qmf_bz + '</td>');
arr.push('<td align="center" height="30px">' + row.dsfzwf + '</td>');
arr.push('<td align="center" height="30px">' + row.ze + '</td>');
arr.push('<td align="center" height="30px">/</td>');
arr.push('<td align="center" height="30px">/</td>');
arr.push('<td align="center" height="30px"></td></tr>'); }
//else中是相同字段的数据
} else {
arr.push('<tr><td colspan="2" align="center" height="30px">' + row.hm + '</td>');
arr.push('<td align="center" height="30px">' + row.mj + '</td>');
arr.push('<td align="center" height="30px">' + row.azbcf + '</td>');
arr.push('<td align="center" height="30px">' + row.grtdbcf + '</td>');
arr.push('<td align="center" height="30px">' + row.jttdbcf + '</td>');
arr.push('<td align="center" height="30px">' + row.qmf_bz + '</td>');
arr.push('<td align="center" height="30px">' + row.dsfzwf + '</td>');
arr.push('<td align="center" height="30px">' + row.ze + '</td>');
arr.push('<td align="center" height="30px">' + row.sfzhm + '</td>');
arr.push('<td align="center" height="30px">' + row.remark + '</td>');
arr.push('<td align="center" height="30px">');
arr.push('<a onclick="toAdd('+ row.id + ')" class="easyui-linkbutton" title="修改" data-options="plain: true,iconCls:\'icon-edit\'"></a> ');
arr.push('<a onclick="toDelet('+ row.id + ')" class="easyui-linkbutton" title="删除" data-options="plain: true,iconCls:\'icon-remove\'"></a></td></tr>');
}
});
//将动态添加的行放在form表单中
$(".TBLForm tbody").html(arr.join(""));
//渲染一下
$.parser.parse($(".TBLForm tbody"));
}
</script>
该模块中有几个小点需要注意:
1. 用数组arr动态的为table添加行,动态数据显示
2. push方法中添加td标签,在该标签中还可加input标签
3. 用list集合进行前后台数据传输
table形式的列表页面显示的更多相关文章
- python 全栈开发,Day114(装饰器,排序规则,显示列,添加按钮,定制ModelForm,自定义列表页面,自定制URL)
一.装饰器 装饰器本质上就是一个python函数,他可以让其他函数在不需要做任何代码变动的前提下,增加额外的功能,装饰器的返回值也是一个函数对象. 装饰器的应用场景:比如插入日志,性能测试,事务处理, ...
- 使用jQuery 中的显示与隐藏动画效果实现折叠下拉菜单的收缩和展开,在页面的列表中有若干项,列表的每项中有一个二级列表,二级列表默认为隐藏状态。点击列表的项,切换二级列表的显示或隐藏状态
查看本章节 查看作业目录 需求说明: 使用jQuery 中的显示与隐藏动画效果实现折叠下拉菜单的收缩和展开,在页面的列表中有若干项,列表的每项中有一个二级列表,二级列表默认为隐藏状态.点击列表的项,切 ...
- 从零开始编写自己的C#框架(22)——添加普通列表页面
普通列表页面指的是上一章那种有层次感列表以外的正常列表页面,由于上一章已讲解了正常添加页面的相关操作了,所以部分相关的操作本章节就不再罗嗦重复一次了.大家可以试试先用本章内容中的一些简单介绍,自己使用 ...
- 利用mybatis的分页插件实现商品列表的显示
分析思路: 当我们点击查询商品的时候,会出现商品的列表,并按上下页可以实现分页的查询的功能. 首先首先我们先找到商品查询商品的按钮在jsp的那个页面,即首页index.jsp 这里有个url即显示商品 ...
- 如何用Mvc实现一个列表页面-异步加载
在接触Mvc后,开始有点觉得很累,什么都要自己做,完全没有WebForm的易用性: 大概用了一个月左右的时候,越用用顺手,就习惯了MVC的这种开发方式,灵活,简洁: 当初学习MVC,网上看资料,都是讲 ...
- 循序渐进VUE+Element 前端应用开发(5)--- 表格列表页面的查询,列表展示和字段转义处理
在我们一般开发的系统界面里面,列表页面是一个非常重要的综合展示界面,包括有条件查询.列表展示和分页处理,以及对每项列表内容可能进行的转义处理,本篇随笔介绍基于Vue +Element基础上实现表格列表 ...
- [ABP教程]第二章 图书列表页面
Web应用程序开发教程 - 第二章: 图书列表页面 关于本教程 在本系列教程中, 你将构建一个名为 Acme.BookStore 的用于管理书籍及其作者列表的基于ABP的应用程序. 它是使用以下技术开 ...
- ASP.NET Aries 入门开发教程2:配置出一个简单的列表页面
前言: 朋友们都期待我稳定地工作,但创业公司若要躺下,也非意念可控. 若人生注定了风雨飘摇,那就雨中前行了. 最机开始看聊新的工作机会,欢迎推荐,创业公司也可! 同时,趁着自由时间,抓紧把这系列教程给 ...
- 基于CkEditor实现.net在线开发之路(5)列表页面开发
这章主要讲解利用控件开发列表页面,我们先从最简单的列表页面开始讲解,这个列表只有一个列表展示.具体开发步骤请看下面动态图 由上动态图可以看出,开发一个简单的列表只有两步, 第一步:拖拽查询控件,设置好 ...
随机推荐
- 如何在网页中浏览和编辑DWG文件 梦想CAD控件
如何在网页中浏览和编辑DWG文件 梦想CAD控件 www.mxdraw.com 梦想绘图控件5.2 是国内最强,最专业的CAD开发组件(控件),不需要AutoCAD就能独立运行.控件使用VC 201 ...
- 梦想CAD控件 2019.01.20更新
下载地址:http://www.mxdraw.com/ndetail_10120.html1. 修改CAD不等比例块保存问题2. 修改CAD捕捉时,Z值对捕捉不准的影响3. 修改图片对象选择后,自动跑 ...
- java动态代理实现与原理详细分析(【转载】By--- Gonjan )
[转载]By---Gonjan 关于Java中的动态代理,我们首先需要了解的是一种常用的设计模式--代理模式,而对于代理,根据创建代理类的时间点,又可以分为静态代理和动态代理. 一.代理模式 ...
- Linux kernel memory-faq.txt
## Linux kernel memory-faq.txt What is some existing documentation on Linux memory management? Ulric ...
- mysql导出数据到excel的两种方式
使用第一种方式如果数据中有换行符的话会自动换行,但使用第二种方式就不会出现这种效果了.两种方式自己选择哈 1:select * from into outfile 'c:/Users/a.xls' t ...
- HDU-4705 Y(思维+dfs树)
Input 4 1 2 1 3 1 4 Output 1 题意:给你一颗树,选择一个三个点构成的集合,使得这三个点不在一条直线上(意思就是 从一个点出发,用一条不回头的线不能将这三个点连起来)问一共有 ...
- ORM优化
orm优化数据库访问:https://docs.djangoproject.com/en/1.11/topics/db/optimization/ 一.QuerySet 可迭代 querysey=mo ...
- apache 添加虚拟机
<VirtualHost *:80> DocumentRoot "E:/UPUPW_AP7.0/htdocs/xd.local/public" ServerName a ...
- python爬虫21 | 对于b站这样的滑动验证码,不好意思,照样自动识别
今天 要来说说滑动验证码了 大家应该都很熟悉 点击滑块然后移动到图片缺口进行验证 现在越来越多的网站使用这样的验证方式 为的是增加验证码识别的难度 那么 对于这种验证码 应该怎么破呢 接下来就是 学习 ...
- elasticsearch数据库使用
elasticsearch的一个最为显著的优点:快速全文检索.关于elasticsearch 全文检索的原理,请看:https://blog.csdn.net/wolfcode_cn/article/ ...