欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

easyui 单元格合并

程序员文章站 2024-02-28 18:50:34
...

需求:

      比较指定列的内容,若一致则合并。

代码:

//指定要合并的列
function mergeCell(){
	mergeCellsByField("dg", "brand,carType,monthPlan,monthAmount,weekDecomposition,weekAmount", 0);
}

//合并车型和品牌
function mergeCellsByField(tableID, colList, mainColIndex) {
    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 i = 0; i <= TableRowCnts ; i++) {
        if (i == TableRowCnts) {
            CurTxt = "";
        }
        else {
            CurTxt = tTable.datagrid("getRows")[i][ColArray[mainColIndex]];
        }
        if (PerTxt == CurTxt) {
            tmpA += 1;
        }
        else {
            tmpB += tmpA;
            for (var j = 0; j < ColArray.length; j++) {
                tTable.datagrid('mergeCells', {
                    index: i - tmpA,
                    field: ColArray[j],
                    rowspan: tmpA,
                    colspan: null
                });
            }
            tmpA = 1;
        }
        PerTxt = CurTxt;
    }
}
推荐博客:http://www.cnblogs.com/senyier/p/3848379.html