/**
* 功能:添加合计行
*
* @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. 使用python 操作liunx的svn,方案一

    在服务器中要做几个操作,使用命令操作svn,svn文件的创建,svn文件更新,并把指定demo路径,移动到创建的文件夹中,进行提交, # -*- coding:utf-8 -*- import pys ...

  2. calayer 的特殊属性整理

    calayer: An object that manages image-based content and allows you to perform animations on that con ...

  3. Struts2通配符

    action: struts: or: 请求路径:

  4. 对极几何(Epipolar Geometry)

    基本概念 对极几何(Epipolar Geometry)是Structure from Motion问题中,在两个相机位置产生的两幅图像的之间存在的一种特殊几何关系,是sfm问题中2D-2D求解两帧间 ...

  5. Linux开启路由的方法

    Linux开启路由的命令很简单,只需要一条命令即可: [root@localhost ~]# echo 1 > /proc/sys/net/ipv4/ip_forward 这个只是临时修改,如果 ...

  6. Python KafkaProducer and KafkaConsumer的开发模块

    1.在python中往kakfa写数据和读取数据,使用的是python-kafka库 2.消费者需持续写入数据,因groupid存在偏移量,才能看看到数据. 3.安装库的命令为pip install ...

  7. 怎样卸载wineQQ?

    好久没实用ubuntu系统的wineqq了.今天用的时候,提示无法使用,要求官网又一次下载新版本号,  感觉挺麻烦的,准备卸载,半天卸载不了. 经过努力,终于还是卸载了. 卸载命令: sudo dpk ...

  8. iOS学小程序从0到发布(适合iOS开发看)

    Emmmm,最近一波失业潮.富某康.某团.摩某.京某.知某.某浪.58 某大面积裁员,那么在这个千钧一发之际,单纯iOS开发也着实不好过,回过头看一下,裁掉的都是单一选手,为了节约成本公司留下的都是身 ...

  9. [iOS]UIInterpolatingMotionEffect重力视觉差

    - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typica ...

  10. vue父子组件之间的传值

    引入组件 父组件 <div> <form-edit></form-edit> </div> import FormEdit from "路径& ...