1、指定列的行合并

* 效果图:

 

* 程序:

  1. function mergeGridColCells(grid,rowFildName)
  2. {
  3. var rows=grid.datagrid('getRows' );
  4. //alert(rows.length);
  5. //alert(rows[1][rowFildName]);
  6. var startIndex=0;
  7. var endIndex=0;
  8. if(rows.length< 1)
  9. {
  10. return;
  11. }
  12. $.each(rows, function(i,row){
  13. if(row[rowFildName]==rows[startIndex][rowFildName])
  14. {
  15. endIndex=i;
  16. }
  17. else
  18. {
  19. grid.datagrid( 'mergeCells',{
  20. index: startIndex,
  21. field: rowFildName,
  22. rowspan: endIndex -startIndex+1
  23. });
  24. startIndex=i;
  25. endIndex=i;
  26. }
  27. });
  28. grid.datagrid( 'mergeCells',{
  29. index: startIndex,
  30. field: rowFildName,
  31. rowspan: endIndex -startIndex+1
  32. });
  33. }
 
*参数说明

grid:        easyUI的datagrid对象
rowFildName: 和并列的field属性值
 
 
 
  1. 源代码如下:

    1. function mergeGridColCells(grid,refCols,rowFildNames)
    2. {
    3. var rows=grid.datagrid('getRows' );
    4. //alert(rows.length);
    5. //alert(rows[1][rowFildName]);
    6. var flag=false ;
    7. var startIndex=0;
    8. var endIndex=0;
    9. if(rows.length< 1)
    10. {
    11. return;
    12. }
    13. $.each(rows, function(i,row){
    14. $.each(refCols, function(j,refCol){
    15. if(row[refCol]!=rows[startIndex][refCol])
    16. {
    17. flag= false;
    18. return false ;
    19. }
    20. else
    21. {
    22. flag= true;
    23. }
    24. });
    25. //if(row[rowFildName]==rows[startIndex][rowFildName])
    26. if(flag)
    27. {
    28. endIndex=i;
    29. }
    30. else
    31. {
    32. $.each(rowFildNames, function(k,rowFildName){
    33. grid.datagrid( 'mergeCells',{
    34. index: startIndex,
    35. field: rowFildName,
    36. rowspan: endIndex -startIndex+1,
    37. colspan: null
    38. });
    39. });
    40. startIndex=i;
    41. endIndex=i;
    42. }
    43. });
    44. $.each(rowFildNames, function(k,rowFildName){
    45. grid.datagrid( 'mergeCells',{
    46. index: startIndex,
    47. field: rowFildName,
    48. rowspan: endIndex -startIndex+1,
    49. colspan: null
    50. });
    51. });
    52. }
  2. 参数说明
    grid:        easyUI的datagrid对象

    refCols        合并参考列数组,及这些列都相等则合并rowFildNames指定的列
    rowFildNames: 和并列的field属性值及要合并的列数组

  3.  
    示例:mergeGridColCells($('#serviceTypeTable'),['serviceTypeId','areaId'],['areaName']);

easyUI单元格合并自定义封装的更多相关文章

  1. asp.net使用控件datagrid实现表头单元格合并

    合并的要点: 1.datagid的单元格合并原理是table中tr,td的布局实现; 2.合并的时机实在其datagridcreate事件中实现; 3.认识一个对象TableCellCollectio ...

  2. SNF快速开发平台MVC-表格单元格合并组件

    1.   表格单元格合并组件 1.1.      效果展示 1.1.1.    页面展现表格合并单元格 图 4.1 1.1.2.    导出excel合并单元格 图 4.2 1.2.      调用说 ...

  3. excel技巧--单元格合并与拆分

    如果要将上图的地区列做成下图的合并单一列: 有如下做法: (以下图表格为例) 1.选择要排序的表格,点击“开始”-->排序和筛选-->自定义排序.在对话框选择“业务项目”进行排序: 2.选 ...

  4. JS:jquery插件表格单元格合并.

    公司需要用到单元格合并,于是动手封装了一个简单的jquery插件,封装的函数是直接写好转的,请多多提意见看代码是否有优化的地方..... 截图: 代码: /* * mergeTable 0.1 * C ...

  5. Qt实现表格控件-支持多级列表头、多级行表头、单元格合并、字体设置等

    目录 一.概述 二.效果展示 三.定制表头 1.重写数据源 2.重写QHeaderView 四.设置属性 五.相关文章 原文链接:Qt实现表格控件-支持多级列表头.多级行表头.单元格合并.字体设置等 ...

  6. ExtJS 4.2 Grid组件的单元格合并

    ExtJS 4.2 Grid组件本身并没有提供单元格合并功能,需要自己实现这个功能. 目录 1. 原理 2. 多列合并 3. 代码与在线演示 1. 原理 1.1 HTML代码分析 首先创建一个Grid ...

  7. NPOI 教程 - 2.1单元格合并

    来源:http://liyingchun343333.blog.163.com/blog/static/3579731620091018212990/ 合并单元格在制作表格时很有用,比如说表格的标题就 ...

  8. DataGridView单元格合并

    本文章转载:http://www.cnblogs.com/xiaofengfeng/p/3382094.html 图: 代码就是如此简单 文件下载:DataGridView单元格合并源码 也可以参考: ...

  9. devexpress实现单元格合并以及依据条件合并单元格

    1.devexpress实现单元格合并非常的简单,只要设置属性[AllowCellMerge=True]就可以了,实现效果如下图: 2.但是在具体要求中并非需要所有的相同单元格都合并,可能需要其他的条 ...

随机推荐

  1. C++初学者 const使用详解

     关于C++中的const关键字的用法非常灵活,而使用const将大大改善程序的健壮性,参考了康建东兄的const使用详解一文,对其中进行了一些补充,写下了本文. 1. const常量 如: cons ...

  2. linux第13天 生产者与消费者

    pthread_cond_t   my_condition = PTHREAD_COND_INITIALIZER; pthread_mutex_t mutex = PTHREAD_MUTEX_INIT ...

  3. struts请求基本类型参数接收

    01:导包,web.xml配置 <?xml version="1.0" encoding="UTF-8"?> <web-app version ...

  4. ECharts切换主题

    初始化接口,返回ECharts实例,其中dom为图表所在节点,theme为可选的主题,内置主题('macarons', 'infographic')直接传入名称,自定义扩展主题可传入主题对象.如: v ...

  5. springmvc处理ajax请求

    1.controller将数据封装成json格式返回页面 @RequestMapping("/dataList") public void datalist(CsoftCunsto ...

  6. VC6.0 error LNK2001: unresolved external symbol _main(转)

    学习VC++时经常会遇到链接错误LNK2001,该错误非常讨厌,因为对于编程者来说,最好改的错误莫过于编译错误,而一般说来发生连接错误时,编译都已通过.产生连接错误的原因非常多,尤其LNK2001错误 ...

  7. 《zw版·Halcon-delphi系列原创教程》 邮票艺术品自动分类脚本

    <zw版·Halcon-delphi系列原创教程> 邮票艺术品自动分类脚本 邮票艺术品自动分类脚本,是个综合应用,有不同尺寸图像的自动识别.区域分割 还有作品附近文字的自动分割 此类项目, ...

  8. Android自动化压力测试快速入门教程(图解)——MonkeyRunner

    一.MonkeyRunner测试环境配置(转自) 1.  android-sdk 下载地址:http://www.android-doc.com/sdk/index.html 下载完成后,只需要解压就 ...

  9. notification 通知

    1. 定义一个方法 -(void) update{ } 2. 对象注册,并关连消息 [[NSNotificationCenter defaultCenter]addObserver:self sele ...

  10. Linux设备驱动工程师之路——内核链表的使用【转】

    本文转载自:http://blog.csdn.net/forever_key/article/details/6798685 Linux设备驱动工程师之路——内核链表的使用 K-Style 转载请注明 ...