<ejs-treegrid #treegrid [dataSource]='data'
[treeColumnIndex]='1' (queryCellInfo)='queryCellInfo($event)'>
<e-columns>
-----
</e-columns>
</ejs-treegrid>
queryCellInfo(args) {
if(args.column.field == "Duration") {
if(args.data.Duration == 5) {
args.colSpan = 2;
// merging 2 columns of same row using colSpan property
}
if(args.data.Duration == 11) {
args.rowSpan = 2;
// merging 2 columns of different row using rowSpan property
}
}
}
|
queryCellInfo(args) {
if(args.column.field == "Duration") {
let currentRowIndex = args.data.index; //current row's index
let lastIndex = this.treegrid.getCurrentViewRecords().length - 1; // last row index
if(lastIndex != currentRowIndex) {
let nextRowData = this.treegrid.getCurrentViewRecords()[currentRowIndex + 1].Duration;
// getting next row's duration column data to compare with current row's duration value.
if(args.data.Duration == nextRowData) {
//if both values are same, setting row span
args.rowSpan = 2;
}
}
}
} |