My Grid has the following structure
$("#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á" }
]
});
I want to merge rows with same value of column [PrepaidMonthName] (call as "Gói dịch vụ"). I don't know if kendo supports merge cells or not yet? What I expect:
Or is there another solution for me to do this?
I found the solution for myself by searching and experimenting, here is the answer to my question:
Currently Kendo grid DOES NOT SUPPORT Merge cells yet, so I need to use pure JS to do this.
I did the following:
$("#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();
}
}
});