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)列表页面开发
这章主要讲解利用控件开发列表页面,我们先从最简单的列表页面开始讲解,这个列表只有一个列表展示.具体开发步骤请看下面动态图 由上动态图可以看出,开发一个简单的列表只有两步, 第一步:拖拽查询控件,设置好 ...
随机推荐
- BeanFactory和ApplicationContext
BeanFactory是一个类的通用工厂,可以创建并管理各种类的对象 Bean工厂是Spring框架最核心的接口,它提供了高级Ioc的配置机制.BeanFeactory使管理不同类的Java对象成为可 ...
- 向appstore提交app流程
http://www.cocoachina.com/newbie/tutorial/2013/0508/6155.html http://blog.csdn.net/holydancer/articl ...
- 第二章 设计高质量的React组件
第二章 设计高质量的React组件 高质量React组件的原则和方法: 划分组件边界的原则: React组件的数据种类: React组件的生命周期. 2.1 易于维护组件的设计要素 1.高内聚:指的是 ...
- TFRecordReader "OutOfRangeError (see above for traceback): RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 1, current size 0)" 问题原因总结;
1. tf.decode_raw(features['image_raw'],tf.uint8) 解码时,数据类型有没有错?tf.float32 和tf.uint8有没有弄混??? 2. tf.tra ...
- instance_name,db_name,oracle_sid之间的关系
一]对ORACLE_SID的理解 --------------------------------------------------------------------------------Ora ...
- Linux学习笔记记录(补充)
- 使用vuex实现父组件调用子组件方法
曲线救国. 核心原理就是父子共用一个vuex对象,且看代码: 父组件parent.vue <template> <div class="wrap"> < ...
- String replaceAll 正则注意事项及特殊用法(xjl456852原创)
我们知道String replaceAll(参数a, 参数b) 参数a是需要些正则表达式的. 但是今天试了试,发现参数b也有一些其它特性. 查看源码后,发现有些特性是平时不怎么用的.下面我来介绍一下这 ...
- Apache 流框架 Flink,Spark Streaming,Storm对比分析(2)
此文已由作者岳猛授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 2.Spark Streaming架构及特性分析 2.1 基本架构 基于是spark core的spark s ...
- java数组知识总结(二)//按操作
一.定长数组 1.构造 直接创建 String[] aArray = new String[5]; String[] bArray = {"a","b",&qu ...