Easyui 合并单元格

时间:2022-11-13 04:30:06

onMyLoadSuccessText: function () {

$(".datagrid-row").mouseover(function () {
var titlestr = $(this).find("div").html();
var tbody = $(this).parent();
tbody.children("tr").each(function () {
if ($(this).find("div").html() == titlestr) {
//$(this).children().eq(0).css("background", "#eaf2ff");
$(this).children().eq(0).addClass("datagrid-row-over");
}
});
});
$(".datagrid-row").mouseout(function () {
var titlestr = $(this).find("div").html();
var tbody = $(this).parent();
tbody.children("tr").each(function () {
if ($(this).find("div").html() == titlestr) {
//$(this).children().eq(0).css("background", "#ffffff");
$(this).children().eq(0).removeClass("datagrid-row-over");
}
});
});

var arr = [{ mergeFiled: "Title", premiseFiled: "Title" }];

//var dg = $("#text"); //要合并的datagrid中的表格id
var dg = $(this);
var rowCount = dg.datagrid("getRows").length;
var cellName;
var span;
var perValue = "";
var curValue = "";
var perCondition = "";
var curCondition = "";
var flag = true;
var condiName = "";
var length = arr.length - 1;
for (i = length; i >= 0; i--) {
cellName = arr[0].mergeFiled;
condiName = arr[0].premiseFiled;
if (Access.isNotNull(condiName)) {
flag = false;
}
perValue = "";
perCondition = "";
span = 1;
for (row = 0; row <= rowCount; row++) {
if (row == rowCount) {
curValue = "";
curCondition = "";
} else {
curValue = dg.datagrid("getRows")[row][cellName];
if (!flag) {
curCondition = dg.datagrid("getRows")[row][condiName];
}
}
if (perValue == curValue && (flag || perCondition == curCondition)) {
span += 1;
} else {
var index = row - span;
dg.datagrid('mergeCells', {
index: index,
field: cellName,
rowspan: span,
colspan: null
});
span = 1;
perValue = curValue;
if (!flag) {
perCondition = curCondition;
}
}
}
}
 
}