Kendo 网格是否支持单元格合并?
Does Kendo Grid support cell merge or not?
我的网格结构如下
$("#grid").kendoGrid({
dataSource: {
data: data,
type: 'json'
},
pageable: true,
columns: [
{ field: "SubServiceTypeName", title: "Sub Type" },
{ field: "PrepaidMonthName", title: "Gói dịch vụ" },
{ field: "DeviceName", title: "Tên thiết bị" },
{ field: "DeviceStatusName", title: "Tình rạng" },
{ field: "IsDeployName", title: "Triển khai" },
{ field: "PriceStatementName", title: "CL giá" }
]
});
结果:
我想合并列 [PrepaidMonthName] 具有相同值的行(称为“Gói dịch vụ”)。不知道kendo是否支持合并单元格?
我的期望:
或者我有其他解决方案吗?
我通过搜索和试验找到了适合自己的解决方案,以下是我的问题的答案:
目前 Kendo 网格 DOES NOT SUPPORT
尚未合并单元格,因此我需要使用纯 JS 来执行此操作。
我做了以下事情:
$("#grid").kendoGrid({
dataSource: {
data: data,
type: 'json'
},
pageable: true,
columns: [
{ field: "SubServiceTypeName", title: "Sub Type" },
{ field: "PrepaidMonthName", title: "Gói dịch vụ" },
{ field: "DeviceName", title: "Tên thiết bị" },
{ field: "DeviceStatusName", title: "Tình rạng" },
{ field: "IsDeployName", title: "Triển khai" },
{ field: "PriceStatementName", title: "CL giá" },
]
});
const table = document.querySelector('.k-grid-content table');
let headerCell = null;
for (let row of table.rows) {
const firstCell = row.cells[1];
if (headerCell === null || firstCell.innerText !== headerCell.innerText) {
headerCell = firstCell;
} else {
headerCell.rowSpan++;
firstCell.remove();
}
}
});
结果:
我的网格结构如下
$("#grid").kendoGrid({
dataSource: {
data: data,
type: 'json'
},
pageable: true,
columns: [
{ field: "SubServiceTypeName", title: "Sub Type" },
{ field: "PrepaidMonthName", title: "Gói dịch vụ" },
{ field: "DeviceName", title: "Tên thiết bị" },
{ field: "DeviceStatusName", title: "Tình rạng" },
{ field: "IsDeployName", title: "Triển khai" },
{ field: "PriceStatementName", title: "CL giá" }
]
});
结果:
我想合并列 [PrepaidMonthName] 具有相同值的行(称为“Gói dịch vụ”)。不知道kendo是否支持合并单元格? 我的期望:
或者我有其他解决方案吗?
我通过搜索和试验找到了适合自己的解决方案,以下是我的问题的答案:
目前 Kendo 网格 DOES NOT SUPPORT
尚未合并单元格,因此我需要使用纯 JS 来执行此操作。
我做了以下事情:
$("#grid").kendoGrid({
dataSource: {
data: data,
type: 'json'
},
pageable: true,
columns: [
{ field: "SubServiceTypeName", title: "Sub Type" },
{ field: "PrepaidMonthName", title: "Gói dịch vụ" },
{ field: "DeviceName", title: "Tên thiết bị" },
{ field: "DeviceStatusName", title: "Tình rạng" },
{ field: "IsDeployName", title: "Triển khai" },
{ field: "PriceStatementName", title: "CL giá" },
]
});
const table = document.querySelector('.k-grid-content table');
let headerCell = null;
for (let row of table.rows) {
const firstCell = row.cells[1];
if (headerCell === null || firstCell.innerText !== headerCell.innerText) {
headerCell = firstCell;
} else {
headerCell.rowSpan++;
firstCell.remove();
}
}
});
结果: