本文主要是介绍easyui 单元格合并,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
需求:
比较指定列的内容,若一致则合并。
代码:
//指定要合并的列
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
这篇关于easyui 单元格合并的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!