/**
* 功能:添加合计行
*
* @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. MySQL存储过程-把一个查询的结果,做为变量,更新另一张表

    create table t1(c1 varchar(20));insert into t1 select 't1'; create table t2(c2 varchar(20));insert i ...

  2. Spring Security 自定义配置(1)

    @Configuration @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapte ...

  3. 【[NOI2011]阿狸的打字机】

    首先发现这个插入的非常有特点,我们可以直接利用这个特殊的性质在\(Trie\)树上模拟指针的进退 之后得到了\(Trie\)树,先无脑建出\(AC\)机 之后考虑一下如何写暴力 最简单的暴力对于每一个 ...

  4. 【问题】 cookie 不保存特殊字符 解决办法

    遇到的问题: 在做项目,用geolocation 获取经纬度,格式如(23.1133,113.2552) ,想保存到cookie中备用.但读取cookie出来之后发现逗号变成了  %2c. 找到的原因 ...

  5. CDN的作用与基本过程

     转载请注明出处: leehao.me 或 https://blog.csdn.net/lihao21/article/details/52808747 简介 CDN,Content Distribu ...

  6. 修改linux系统的默认语言

    修改linux系统的默认语言: 1.全局修改:         所有用户都是同一种统一的语言设置          修改/etc/sysconfig/i18n文件          vi /etc/s ...

  7. EF Core 2.0 已经支持自动生成父子关系表的实体

    现在我们在SQL Server数据库中有Person表如下: CREATE TABLE [dbo].[Person]( ,) NOT NULL, ) NULL, ) NULL, ) NULL, [Cr ...

  8. 用JavaScript编写气泡

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

  9. java ssm 后台框架平台 项目源码 websocket 即时通讯 IM quartz springmvc

    官网 http://www.fhadmin.org/D 集成安全权限框架shiro  Shiro 是一个用 Java 语言实现的框架,通过一个简单易用的 API 提供身份验证和授权,更安全,更可靠E ...

  10. Activiti6.0 spring5 工作流引擎 java SSM流程审批 项目框架

    1.模型管理 :web在线流程设计器.预览流程xml.导出xml.部署流程 2.流程管理 :导入导出流程资源文件.查看流程图.根据流程实例反射出流程模型.激活挂起 3.运行中流程:查看流程信息.当前任 ...