/**
* 功能:添加合计行
*
* @param table
* 指定的KDTable
* @param fields
* 需要合计的列
*/
public static void apendFootRow(KDTable table, String fields[]) {
int size = fields.length;
if (size == 0)
return;
Map sumValue = new HashMap();
// 利用getRowCount的到的行可能不正确
int count = table.getRowCount3(); for (int i = 0; i < fields.length; i++) {
sumValue.put(fields[i], new BigDecimal("0.00"));
}
IRow footRow = null;
KDTFootManager footManager = table.getFootManager();
if (footManager == null) {
footManager = new KDTFootManager(table);
footManager.addFootView();
table.setFootManager(footManager);
}
// 计算所有指定行的合计值
footRow = footManager.getFootRow(0);
for (int i = 0; i < count; i++) {
IRow row = table.getRow(i);
for (int j = 0; j < fields.length; j++) {
sumValueForCell(row, fields[j], sumValue);
}
} if (footRow == null) {
footRow = footManager.addFootRow(0);
}
// 设置合计行显示样式
String colFormat = "%{0.00}f"; String total = EASResource.getString(FrameWorkClientUtils.strResource
+ "Msg_Total"); table.getIndexColumn().setWidthAdjustMode(KDTIndexColumn.WIDTH_MANUAL);
table.getIndexColumn().setWidth(30);
footManager.addIndexText(0, total);
footRow.getStyleAttributes().setBackground(new Color(0xf6, 0xf6, 0xbf));
for (int i = 0; i < size; i++) {
String colName = fields[i];
footRow.getCell(colName).getStyleAttributes().setNumberFormat(
colFormat);
footRow.getCell(colName).getStyleAttributes().setHorizontalAlign(
HorizontalAlignment.RIGHT);
footRow.getCell(colName).getStyleAttributes().setFontColor(
Color.black);
} // 设置合计行的值
for (int i = 0; i < fields.length; i++) {
footRow.getCell(fields[i]).setValue(sumValue.get(fields[i]));
}
} private static void sumValueForCell(IRow row, String key, Map sumValue) {
ICell cell = row.getCell(key); if (cell != null) {
Object obj = cell.getValue();
if (obj != null) {
BigDecimal keyValue = (BigDecimal) sumValue.get(key);
keyValue = keyValue.add(new BigDecimal(obj.toString()));
sumValue.put(key, keyValue);
}
}
}

KDTable如何添加合计行?的更多相关文章

  1. winform DataGridView添加合计行

    使用方法 /* DataTable dt= DBUtility.DB.FromSql(sql).ToDataTable(); DataGridViewAddSumRow sumRow = new Da ...

  2. Gridview里添加合计行

    ShowFooter="true" ; ; ; protected void gvIncomeYG_RowDataBound(object sender, GridViewRowE ...

  3. jqGrid 添加 合计行 footDate

    jQuery(table_id).jqGrid({ url : url,//组件创建完成之后请求数据的url datatype : "json",//请求数据返回的类型.可选jso ...

  4. C#给DataTable添加序号、C#给DataTable添加合计、小计

    /// <summary>        /// 给DataTable添加序号        /// </summary>        /// <param name= ...

  5. FineUI大版本升级,外置ExtJS库、去AXD化、表格合计行、表格可编辑单元格的增删改、顶部菜单框架

    这是一篇很长的文章,在开始正文之前,请允许我代表目前排名前 20 中唯一的 .Net 开源软件 FineUI 拉下选票: 投票地址: https://code.csdn.net/2013OSSurve ...

  6. UI组件--element-ui--Table组件自定义合计行

    需求: Element-ui的Table组件自带合计行, 但是需求需要在合计行的某些单元格有特别的样式以及事件, 没有研究出怎么在既有合计行上完成此需求, 于是利用其原本的一些属性完成自定义合计行. ...

  7. UI组件--element-ui合计行在横向滚动条下面的解决方法

    使用element-ui合计功能, 因列数较多, 产生横向滚动条: 但是合计行却在滚动条下面, 拖动滚动条合计行不会跟着横向滚动. 在当前页面添加以下样式: <style lang='less' ...

  8. 分享一个带有合计行功能的DataGridView扩展

    因为一个Winform的项目中需要用到带有合计行的表格,并且需要满足以下需求: 合计行可自动对需要求和的列进行求和计算; 合计行必须固定(冻结)在表格的最底部,且其位置不受滚动条的滚动而移动; 可以设 ...

  9. layui 合计行不要边框

    $(".layui-table-total div").attr('style','text-overflow:clip'); //合并合计行单元格 $(".layui- ...

随机推荐

  1. Phonegap 目录结构介绍

    1.Src 该目录包含了所有用户要创建的 Java 源文件 2.gen 为开发工具自动创建 3.assets 目录 用于方一些资源文件 css js html 4.res 目录该目录包含了所有的资源文 ...

  2. struts2 FilterDispatcher 和 StrutsPrepareAndExecuteFilter 的区别(转)

    FilterDispatcher是struts2.0.x到2.1.2版本的核心过滤器.! StrutsPrepareAndExecuteFilter是自2.1.3开始就替代了FilterDispatc ...

  3. angularjs select下拉搜索框

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 【Vue】hello world

    参考链接:http://www.jianshu.com/p/5ba253651c3b 1.Vue 是一个前端框架,特点是数据绑定.组件化 如果你之前已经习惯了用jQuery操作DOM,学习Vue.js ...

  5. LayIM.AspNetCore Middleware 开发日记(五)Init接口实现细节

    前言 “一旦开始了就要坚持下去“.为什么本文的第一句话是这么一句话呢,因为我经常就是开头轰轰烈烈,结果越来越枯燥,就不想做下去了.但是版图就放弃又那么不甘心,继续加油吧. 吐槽完毕,进入正题.在上一篇 ...

  6. ThinkPHP5入门(四)----模板篇

    一.模板访问 1.没有参数传递 $view = new View(); return $view->fetch(); 此时默认访问的模板路径为:[模板文件目录]/当前控制器名(小写+下划线)/当 ...

  7. 搭建elk的坑

    npm install  时总是报phantomjs-prebuilt@2.1.16安装失败: npm cache clean --force npm -g install phantomjs-pre ...

  8. Springboot时间参数格式化

    @Configuration public class DateTimeFormatConfiguration extends WebMvcConfigurerAdapter { @Value(val ...

  9. CCF认证201809-2买菜

    问题描述 小H和小W来到了一条街上,两人分开买菜,他们买菜的过程可以描述为,去店里买一些菜然后去旁边的一个广场把菜装上车,两人都要买n种菜,所以也都要装n次车.具体的,对于小H来说有n个不相交的时间段 ...

  10. 图形剖析,当给 ul 设置padding=0, margin=0后 li前面的小黑点消失的现象原理!