开发者社区> 问答> 正文

easyUI datagrid合并单元格后一点小调整?

atagrid中将相同的列合并单元格成功,代码也是我在网上找的直接用的,但是合并单元格后:

第一行都会连着那个合并的单元格screenshot

function mergeCellsByField(tableID, colList) {
        var ColArray = colList.split(",");
        var tTable = $('#' + tableID);
        var TableRowCnts = tTable.datagrid("getRows").length;
        var tmpA;
        var tmpB;
        var PerTxt = "";
        var CurTxt = "";
        var alertStr = "";
        for (var j = ColArray.length - 1; j >= 0; j--) {
            // 当循环至某新的列时,变量复位。
            PerTxt = "";
            tmpA = 1;
            tmpB = 0;
            // 从第一行(表头为第0行)开始循环,循环至行尾(溢出一位)
            for (var i = 0; i <= TableRowCnts; i++) {
                if (i == TableRowCnts) {
                    CurTxt = "";
                } else {
                    CurTxt = tTable.datagrid("getRows")[i][ColArray[j]];
                }
                if (PerTxt == CurTxt) {
                    tmpA += 1;
                } else {
                    tmpB += tmpA;
                    tTable.datagrid('mergeCells', {
                        index : i - tmpA,
                        field : ColArray[j],
                        rowspan : tmpA,
                        colspan : null
                    });
                    tmpA = 1;
                }
                PerTxt = CurTxt;
            }
        }
    }
onLoadSuccess : function(data) {
            if (data.rows.length > 0) {
                mergeCellsByField("myTable", "costname");
            }
        },

展开
收起
a123456678 2016-07-12 17:00:47 2892 0
1 条回答
写回答
取消 提交回答
  • #center  .datagrid-row-selected  
           { 
              background: transparent; 
              color: #000000; 
           } 
          #center .datagrid-row-over, 
          #center .datagrid-header td.datagrid-header-over  
          { 
              background: transparent; 
              color: #000000; 
              cursor: default; 
          }
    
     #center td:hover {
              background: #95B8E7;
          } 
    2019-07-17 19:55:16
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载