KDTable如何添加合计行?
/**
* 功能:添加合计行
*
* @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如何添加合计行?的更多相关文章
- winform DataGridView添加合计行
使用方法 /* DataTable dt= DBUtility.DB.FromSql(sql).ToDataTable(); DataGridViewAddSumRow sumRow = new Da ...
- Gridview里添加合计行
ShowFooter="true" ; ; ; protected void gvIncomeYG_RowDataBound(object sender, GridViewRowE ...
- jqGrid 添加 合计行 footDate
jQuery(table_id).jqGrid({ url : url,//组件创建完成之后请求数据的url datatype : "json",//请求数据返回的类型.可选jso ...
- C#给DataTable添加序号、C#给DataTable添加合计、小计
/// <summary> /// 给DataTable添加序号 /// </summary> /// <param name= ...
- FineUI大版本升级,外置ExtJS库、去AXD化、表格合计行、表格可编辑单元格的增删改、顶部菜单框架
这是一篇很长的文章,在开始正文之前,请允许我代表目前排名前 20 中唯一的 .Net 开源软件 FineUI 拉下选票: 投票地址: https://code.csdn.net/2013OSSurve ...
- UI组件--element-ui--Table组件自定义合计行
需求: Element-ui的Table组件自带合计行, 但是需求需要在合计行的某些单元格有特别的样式以及事件, 没有研究出怎么在既有合计行上完成此需求, 于是利用其原本的一些属性完成自定义合计行. ...
- UI组件--element-ui合计行在横向滚动条下面的解决方法
使用element-ui合计功能, 因列数较多, 产生横向滚动条: 但是合计行却在滚动条下面, 拖动滚动条合计行不会跟着横向滚动. 在当前页面添加以下样式: <style lang='less' ...
- 分享一个带有合计行功能的DataGridView扩展
因为一个Winform的项目中需要用到带有合计行的表格,并且需要满足以下需求: 合计行可自动对需要求和的列进行求和计算; 合计行必须固定(冻结)在表格的最底部,且其位置不受滚动条的滚动而移动; 可以设 ...
- layui 合计行不要边框
$(".layui-table-total div").attr('style','text-overflow:clip'); //合并合计行单元格 $(".layui- ...
随机推荐
- CSS3动画中的位置设定问题
水平居中的不同方法实现: position: absolute; margin: auto; left:; right:; position: absolute; left:%; -webkit-tr ...
- 关于javascript的单线程和异步的一些问题
关于js单线程和异步方面突然就糊涂了,看别人的文章越看越糊涂,感觉这方面是个坑,跳进去就不好跳出来.再去看,看着看着感觉自己明白了一些东西,也不知道对不对,反正是暂时把自己说服了,这样理解能理解的通, ...
- PostgreSQL 常用的命令
连接数据库: psql -h ip -U usrname查看所有库: \l查看所有表: \dt查看某个表的结构: \d 表名查看数据库中所有的表: select * from pg_tables;查看 ...
- 数论——算数基本定理 - HDU 4497 GCD and LCM
GCD and LCM Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total ...
- IIs和ftp
简单的说,FTP就是完成两台计算机之间的拷贝,从远程计算机拷贝文件至自己的计算机上,称之为“下载(download)”文件.若将文件从自己计算机中拷贝至远程计算机上,则称之为“上载(upload)”文 ...
- EasyConnect 使用方法
一.此处以安卓系统为例进行介绍. 1.通过谷歌市场下载 EasyConnect,安装完成后,打开EasyConnect,界面如下图 1 所示 <ignore_js_op> 2.输入 SSL ...
- QTP基本方法
1.for循环: m代表间隔循环长度: 如果m>0,则j要大于i: 如果m<0,则i要大于j: for i to j [step m] 语句块 [exit for]//强制退出循环 nex ...
- 关于CUDA5之后cutil.h不可用的问题
用CUDA进行GPU加速开发的同学在移植一些代码片段时应该都有过这样的经历,如果自己用的是高版本的CUDA,系统有时会报错:CANNOT FIND CUTIL.H.查看代码才发现原来是多了CUTIL. ...
- .NET完全手动搭建三层B/S架构
简介:三层架构(3-tier application) 通常意义上的三层架构就是将整个业务应用划分为:表现层(WebUI).业务逻辑层(BusinessLogicLayer).数据访问层(DataAc ...
- POJ 2299 Ultra-QuickSort 求逆序数 (归并或者数状数组)此题为树状数组入门题!!!
Ultra-QuickSort Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 70674 Accepted: 26538 ...