(该案例在项目中的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">备&nbsp;&nbsp;&nbsp;&nbsp;注</td>
<td rowspan="2" align="center" height="30px">操&nbsp;&nbsp;&nbsp;&nbsp;作</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形式的列表页面显示的更多相关文章

  1. python 全栈开发,Day114(装饰器,排序规则,显示列,添加按钮,定制ModelForm,自定义列表页面,自定制URL)

    一.装饰器 装饰器本质上就是一个python函数,他可以让其他函数在不需要做任何代码变动的前提下,增加额外的功能,装饰器的返回值也是一个函数对象. 装饰器的应用场景:比如插入日志,性能测试,事务处理, ...

  2. 使用jQuery 中的显示与隐藏动画效果实现折叠下拉菜单的收缩和展开,在页面的列表中有若干项,列表的每项中有一个二级列表,二级列表默认为隐藏状态。点击列表的项,切换二级列表的显示或隐藏状态

    查看本章节 查看作业目录 需求说明: 使用jQuery 中的显示与隐藏动画效果实现折叠下拉菜单的收缩和展开,在页面的列表中有若干项,列表的每项中有一个二级列表,二级列表默认为隐藏状态.点击列表的项,切 ...

  3. 从零开始编写自己的C#框架(22)——添加普通列表页面

    普通列表页面指的是上一章那种有层次感列表以外的正常列表页面,由于上一章已讲解了正常添加页面的相关操作了,所以部分相关的操作本章节就不再罗嗦重复一次了.大家可以试试先用本章内容中的一些简单介绍,自己使用 ...

  4. 利用mybatis的分页插件实现商品列表的显示

    分析思路: 当我们点击查询商品的时候,会出现商品的列表,并按上下页可以实现分页的查询的功能. 首先首先我们先找到商品查询商品的按钮在jsp的那个页面,即首页index.jsp 这里有个url即显示商品 ...

  5. 如何用Mvc实现一个列表页面-异步加载

    在接触Mvc后,开始有点觉得很累,什么都要自己做,完全没有WebForm的易用性: 大概用了一个月左右的时候,越用用顺手,就习惯了MVC的这种开发方式,灵活,简洁: 当初学习MVC,网上看资料,都是讲 ...

  6. 循序渐进VUE+Element 前端应用开发(5)--- 表格列表页面的查询,列表展示和字段转义处理

    在我们一般开发的系统界面里面,列表页面是一个非常重要的综合展示界面,包括有条件查询.列表展示和分页处理,以及对每项列表内容可能进行的转义处理,本篇随笔介绍基于Vue +Element基础上实现表格列表 ...

  7. [ABP教程]第二章 图书列表页面

    Web应用程序开发教程 - 第二章: 图书列表页面 关于本教程 在本系列教程中, 你将构建一个名为 Acme.BookStore 的用于管理书籍及其作者列表的基于ABP的应用程序. 它是使用以下技术开 ...

  8. ASP.NET Aries 入门开发教程2:配置出一个简单的列表页面

    前言: 朋友们都期待我稳定地工作,但创业公司若要躺下,也非意念可控. 若人生注定了风雨飘摇,那就雨中前行了. 最机开始看聊新的工作机会,欢迎推荐,创业公司也可! 同时,趁着自由时间,抓紧把这系列教程给 ...

  9. 基于CkEditor实现.net在线开发之路(5)列表页面开发

    这章主要讲解利用控件开发列表页面,我们先从最简单的列表页面开始讲解,这个列表只有一个列表展示.具体开发步骤请看下面动态图 由上动态图可以看出,开发一个简单的列表只有两步, 第一步:拖拽查询控件,设置好 ...

随机推荐

  1. java操作zip文件

    思路: 1).读取zip中的文件并将除了重名文件之外的文件转存到中转zip文件中. 2).往中转文件中插入txt文件. 3).删除原zip文件. 4).将中转zip文件重命名为原zip文件. 前提,t ...

  2. vue项目国际化实现 vue-i18n使用详细教程

    1.安装vue-i18n: npm i vue-i18n -S 当然你也可以这样: <script src="https://unpkg.com/vue/dist/vue.js&quo ...

  3. Oracle中的COALESCE,NVL,NVL2,NULLIF函数

    http://jingyan.baidu.com/article/fa4125acaf898e28ac7092b9.html

  4. DBDA

    <?php class DBDA{ public $host = "localhost"; //服务器地址 public $uid = "root"; / ...

  5. [Algorithm] 8. Rotate String

    Description Given a string and an offset, rotate string by offset. (rotate from left to right) Examp ...

  6. linux ltrace-跟踪进程调用库函数的情况

    当前位置:硬件 | 监测 | 内核 | Shell / 性能监测与优化 /ltrace ltrace命令是用来跟踪进程调用库函数的情况. 语法 ltrace [option ...] [command ...

  7. Python selenium chrome打包exe后禁用控制台输出滚动日志

    Python selenium chrome打包exe后,在运行的过程中,如果遇到需要input()输入时,会发现被不断滚动刷新的日志把命令行输入快速顶掉了,通过查阅资料不断实践,发现以下方法有效: ...

  8. Literature Review on Tidal Turbine

    source: scopus , SCIE keywords in tilte: tidal turbine Software: Bibliometrix

  9. 【Codeforces 584D】Dima and Lisa

    [链接] 我是链接,点我呀:) [题意] 让你把一个奇数n分成最多个质数的和 [题解] 10的9次方以内,任意两个质数之间的差距最大为300 因此可以这样,我们先从i=n-2开始一直递减直到i变成最大 ...

  10. Leetcode 87.扰乱字符串

    扰乱字符串 给定一个字符串 s1,我们可以把它递归地分割成两个非空子字符串,从而将其表示为二叉树. 下图是字符串 s1 = "great" 的一种可能的表示形式. 在扰乱这个字符串 ...