- 注册时间
- 2015-10-15
- 最后登录
- 2023-9-19
- 阅读权限
- 10
- 积分
- 370
- 精华
- 0
- 帖子
- 21
|
function onLoad(e) {
//debugger
var grid = e.sender;
var rows = e.data;
var str = "[";
var deptname = "";
var strs = "";
var arr = new Array();
var j = 0;
//debugger
for (var i = 0, l = rows.length; i < l; i++) {
deptname = rows["DeptName"];
var r = rows.filter(function (a) {
return a.DeptName == deptname;
});
var exsnum = r.length;
if (arr.indexOf(deptname) < 0) {
arr.push(deptname);
j = 1;
} else { j = 0;}
if (exsnum > 1) {
if (j==1) {
strs += ",{\"rowIndex\": " + i + ", \"columnIndex\": 0, \"rowSpan\": " + exsnum + ", \"colSpan\": 1}";
strs += ",{\"rowIndex\": " + i + ", \"columnIndex\": 1, \"rowSpan\": " + exsnum + ", \"colSpan\": 1}";
strs += ",{\"rowIndex\": " + i + ", \"columnIndex\": 10,\" rowSpan\": " + exsnum + ", \"colSpan\": 1}";
}
}
}
if (strs.length > 0) { strs = strs.substring(1); }
str += strs + "]";
var marges = JSON.parse(str);
//var marges1 = [{ rowIndex: 0, columnIndex: 0, rowSpan: 2, colSpan: 1 }, { rowIndex: 0, columnIndex: 1, rowSpan: 2, colSpan: 1 }, { rowIndex: 0, columnIndex: 10, rowSpan: 2, colSpan: 1 }, { rowIndex: 3, columnIndex: 0, rowSpan: 3, colSpan: 1 }, { rowIndex: 3, columnIndex: 1, rowSpan: 3, colSpan: 1 }, { rowIndex: 3, columnIndex: 10, rowSpan: 3, colSpan: 1 }];
grid.mergeCells(marges);
}
这样前两列合并成功 但是第10的列没有合并
var marges1 = [{ rowIndex: 0, columnIndex: 0, rowSpan: 2, colSpan: 1 }, { rowIndex: 0, columnIndex: 1, rowSpan: 2, colSpan: 1 }, { rowIndex: 0, columnIndex: 10, rowSpan: 2, colSpan: 1 }, { rowIndex: 3, columnIndex: 0, rowSpan: 3, colSpan: 1 }, { rowIndex: 3, columnIndex: 1, rowSpan: 3, colSpan: 1 }, { rowIndex: 3, columnIndex: 10, rowSpan: 3, colSpan: 1 }];
grid.mergeCells(marges1);
直接这样一模一样拼接出来的第10的列就能合并 很奇怪的 下面的就是上面拼接的内容
|
|