两个参数
/**合并单元格:合并指定 gridName表格的NoName 列,合并的标准是参考CellName+CellNameTwo列内单元格的值。
* gridName :表格名称
* NoName:合并单元格列名称
* CellName:参考列名称
*/
function mergerNo (gridName, NoName, CellName,CellNameTwo){
var mya = $("#" + gridName + "").getDataIDs();//返回表格中id
var length = mya.length;
for (var i = 0; i < length; i++) {
var before = $("#" + gridName + "").jqGrid('getRowData', mya[i]);
var rowSpanTaxCount = 1;
var rowspannum=0;
var beforState = before[CellName]+before[CellNameTwo];
console.log("beforState"+beforState);
for (j = i + 1; j <= length; j++) {
//和上边的信息对比 如果值一样就合并行数+1 然后设置rowspan 让当前单元格隐藏
var end = $("#" + gridName + "").jqGrid('getRowData', mya[j]);
var endState = end[CellName]+end[CellNameTwo];
if (beforState == endState) {
rowSpanTaxCount++;
$("#" + gridName + "").setCell(mya[j], NoName, '', { display: 'none' });
} else {
rowspannum=rowSpanTaxCount;
rowSpanTaxCount = 1;
break;
}
}
$("#" + NoName + "" + mya[i] + "").attr("rowspan", rowspannum);
}
}