Column & Row Spanning
Description
Demo
Basic Usage
import type { Column, GridOption, ItemMetadata } from 'angular-slickgrid';
@Component({
styleUrls: ['grid43.component.scss'],
templateUrl: './grid43.component.html',
encapsulation: ViewEncapsulation.None,
})
export class Grid43Component implements OnInit {
gridOptions: GridOption;
columnDefinitions: Column[];
dataset: any[] = [];
// metadata can be dynamic too, it doesn't have to be preset
metadata: ItemMetadata | Record<number, ItemMetadata> = {
0: {
columns: {
1: { rowspan: 2 },
2: { colspan: 2 },
10: { colspan: 3, rowspan: 10 },
13: { colspan: 2 },
17: { colspan: 2, rowspan: 2 },
},
}
};
ngOnInit(): void {
// define the grid options & columns and then create the grid itself
this.defineGrid();
}
defineGrid() {
this.columnDefinitions = [ /*...*/ ];
this.gridOptions = {
enableCellNavigation: true,
enableCellRowSpan: true, // required for rowspan to work
dataView: {
globalItemMetadataProvider: {
getRowMetadata: (_item, row) => {
return this.metadata[row];
},
},
},
rowTopOffsetRenderType: 'top', // rowspan doesn't render well with 'transform', default is 'top'
};
}
}Last updated