继续潜水

导航

 
.......
onLoadSuccess : function(data) { if (data.rows.length > 0) { //调用mergeCellsByField()合并单元格 mergeCellsByField("grid","supply_fullname,in_supply,in_no,in_sales"); } } /*
tableID
:表格的ID
colList:需要合并的列,如果有多个,可以以,分开
*/
function mergeCellsByField(tableID, colList) { //alert(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 (j = ColArray.length - 1; j >= 0; j--) { PerTxt = ""; tmpA = 1; tmpB = 0; for (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 }); tTable.datagrid("mergeCells", { //根据ColArray[j]进行合并 index: i - tmpA, field: "Ideparture", rowspan: tmpA, colspan: null }); tmpA = 1; } PerTxt = CurTxt; } } }

此处分2段代码,

1,放在easyui   datagrid 中的onLoadSuccess 方法中,调用mergeCellsByField (tableID, colList),参数tableID 为 表格的id , colList为需要合并的单元的字段已","分割,

2,为mergeCellsByField()方法

 

posted on 2016-02-26 08:42  继续潜水  阅读(2927)  评论(0编辑  收藏  举报