easyui —— footer
前言:
使用easyui的datagrid,在最后一行加上“总计”字样,效果如下:

过程:
...
<table id="dg" title="xx管理" fitColumns="true" pagination="true" rownumbers="true" nowrap="true"
fit="true" toolbar="#tb" data-options="pageSize:25,pageList:[10,15,25,50,100],singleSelect:true,showFooter: true">
<thead>
<tr id="options">
<th data-options="field:'id',width:50,align:'center'">编号</th>
<th data-options="field:'name',width:150,align:'center'">名称</th>
<th data-options="field:'remark',width:100,align:'center'">备注</th>
<th data-options="field:'addr',width:130,align:'center'">地区</th>
<th data-options="field:'percount',width:50,align:'center',sortable:true">人数</th>
<th data-options="field:'chatCount',width:50,align:'center'">聊天条数</th>
<th data-options="field:'createtime',width:100,align:'center',formatter:formatReg">创建时间</th>
<th field="operate" width="120" align="center" data-options="formatter:formatOperate" >操作</th>
</tr>
</thead>
</table>
...
在data-option中增加showFooter属性为true,并在后台准备数据的时候增加footer属性,并且其中字段名跟数据库中的保持一致:
...
return this.json({total: result.count, rows: result.data,footer:[{"name":"总计","percount":personTotal,"chatCount":chatTotal}]});
...
但是,莫名其妙的出现了下面的情景:

就是在最后一栏“操作”中出现了不该出现的三个按钮,解决方法:在后台组织返回数据的时候,增加一个属性,比如:
...
return this.json({total: result.count, rows: result.data,footer:[{"isFooter":true,"name":"总计","percount":personTotal,"chatCount":chatTotal}]});
...
然后在前台代码上增加一个判断:
...
function formatOperate(value, row, index){
var update = '<a onclick="openUpdateDialog('+index+')" href="javascript:void(0)" title="修改" class="linkbutton" data-options="plain:true,iconCls:\'icon-page_edit\'"></a>';
var delStr='<a onclick="del('+row.id+')" href="javascript:void(0)" title="删除" class="linkbutton" data-options="plain:true,iconCls:\'icon-delete\'"></a>';
var checkUsers ='<a onclick="checkUsers('+index+')" href="javascript:void(0)" title="查看圈子成员" class="linkbutton" data-options="plain:true,iconCls:\'icon-group\'"></a>';
if(!row.isFooter){
return checkUsers+ " "+update+ " "+delStr;
}else{
return "";
}
}
...
后言:
这样便完美的解决了footer中出现的问题。
easyui —— footer的更多相关文章
- easyUI footer 的格式渲染
网上好多的例子,但是自己使用的情况下还是出现bug.比如以下代码: var myview = $.extend({}, $.fn.datagrid.defaults.view, { renderFoo ...
- EasyUI DataGrid 添加 Footer
做后台管理界面时,EasyUI 的 DataGrid 经常会被用到,有时候一些总的统计数据不合适放在数据表格里,需要单独显示,这时候就可以放在Footer中显示而不必另外布局. 该怎么给 DataGr ...
- Jquery EasyUI的datagrid页脚footer使用及数据统计
最近做一个统计类的项目中遇到datagrid数据显示页脚footer合计的问题,对于构造统计结果数据格式,是在程序端构造一个{"rows":[],"total" ...
- easyui datagrid footer 页脚问题
mvc 的一个例子 public string IndexV2() { var dataGridJson = new DataGridJson(); var data = new List<My ...
- easyui datagrid 显示 footer
1.设置 showFooter为true $grid = $dg.datagrid({ // fit: true, //fitColumns: true, // pagination: false, ...
- EasyUi Datagrid中footer renderFooter
默认的'rowStyler' 选项不支持footer,想让footer支持rowStyler的话,dategird就得重写.代码如下. var myview = $.extend({}, $.fn.d ...
- 关于easyui datagrid 表格数据处理
首先先将easyui 引入到jsp页面中 <link rel="stylesheet" type="text/css" href="easyui ...
- 【开源】OSharp框架解说系列(2.1):EasyUI的后台界面搭建及极致重构
OSharp是什么? OSharp是个快速开发框架,但不是一个大而全的包罗万象的框架,严格的说,OSharp中什么都没有实现.与其他大而全的框架最大的不同点,就是OSharp只做抽象封装,不做实现.依 ...
- Easyui简单布局
1.创建布局 创建布局只需要添加 'easyui-layout' class 到 <div> 标记或者 在整个页面创建布局,即<body class="easyui-lay ...
随机推荐
- spark与flume整合
spark-streaming与flume整合 push package cn.my.sparkStream import org.apache.spark.SparkConf import org ...
- platform_driver_probe 函数解析
结构体列举 // 几个结构体 // include/linux/device.h struct bus_type { const char *name; // "platform" ...
- AX88772B 驱动移植
Linux kernel 3.2.0 捏自带的AX88772B 不稳定,现用 AX88772B 官方的驱动进行移植测试. 驱动下载地址: http://www.asix.com.tw/cs/produ ...
- kernel 生成uImage
有些u-boot 指定要链接uImage 所以今天记录一下kernel 生成uImage 的条件 在kernel 配置完make menuconfig 后,进行编译,发现make uImage 生成不 ...
- JVM 详谈
JVM 详谈 本来这次应该讲讲ORM 的几个框架,但是笔者还没有完全总结出来,所以这里先插入一次学习JVM的心得.作为一个Java程序员,如果不了解JVM的工作原理,就很难从底层去把 握Java语言和 ...
- HDU 5289 Assignment(多校2015 RMQ 单调(双端)队列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5289 Problem Description Tom owns a company and he is ...
- LINQ操作符二:SelectMany
SelectMany操作符提供了将多个from子句组合起来的功能,相当于数据库中的多表连接查询,它将每个对象的结果合并成单个序列. 示例: student类: using System; using ...
- HTML坦克大战学习02---坦克动起来
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...
- TypeError: datetime.datetime(2016, 9, 25, 21, 12, 19, 135649) is not JSON serializable解决办法(json无法序列化对象的解决办法)
1.一个简单的方法来修补json模块,这样序列将支持日期时间. import json import datetime json.JSONEncoder.default = lambda self, ...
- 什么是Apache ZooKeeper?
Apache ZooKeeper是由集群(节点组)使用的一种服务,用于在自身之间协调,并通过稳健的同步技术维护共享数据.ZooKeeper本身是一个分布式应用程序,为写入分布式应用程序提供服务. Zo ...