@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
88 lines (87 loc) • 4.17 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { Component, Input } from '@angular/core';
import { DetailTemplateDirective } from '../details/detail-template.directive';
import { ColumnBase } from "../../columns/column-base";
import { columnsToRender } from '../../columns/column-common';
import { isNullOrEmptyString, isTruthy } from '../../utils';
import { NgFor, NgIf } from '@angular/common';
import { ContextService } from '../../common/provider.service';
import * as i0 from "@angular/core";
import * as i1 from "../../common/provider.service";
/**
* @hidden
*/
export class ColGroupComponent {
ctx;
columns = [];
groups = [];
detailTemplate;
sort = new Array();
constructor(ctx) {
this.ctx = ctx;
}
getColumnWidth(column) {
const columnWidth = column.width ? `${column.width}px` : undefined;
return this.isStacked ? '100%' : columnWidth;
}
get columnsToRender() {
return this.isStacked ? [new ColumnBase()] : columnsToRender(this.columns);
}
get isStacked() {
return this.ctx.grid?.isStacked;
}
trackBy(index) {
return index;
}
isSorted(column) {
const state = this.sortDescriptor(column.field);
return this.isSortable(column) && (state.dir === 'asc' || state.dir === 'desc');
}
getColumnComponent(column) {
return column;
}
isSortable(column) {
return !isNullOrEmptyString(column.field) && isTruthy(column.sortable);
}
sortDescriptor(field) {
return this.sort.find(item => item.field === field) || { field };
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColGroupComponent, deps: [{ token: i1.ContextService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ColGroupComponent, isStandalone: true, selector: "[kendoGridColGroup]", inputs: { columns: "columns", groups: "groups", detailTemplate: "detailTemplate", sort: "sort" }, ngImport: i0, template: `
<ng-container>
<col [class.k-group-col]="true" *ngFor="let g of groups" />
<col [class.k-hierarchy-col]="true" *ngIf="detailTemplate?.templateRef && !isStacked"/>
<col *ngFor="let column of columnsToRender; trackBy: trackBy;"
[style.width]="getColumnWidth(column)"
[class.k-sorted]="isSorted(getColumnComponent(column))"/>
</ng-container>
`, isInline: true, dependencies: [{ kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColGroupComponent, decorators: [{
type: Component,
args: [{
selector: '[kendoGridColGroup]',
template: `
<ng-container>
<col [class.k-group-col]="true" *ngFor="let g of groups" />
<col [class.k-hierarchy-col]="true" *ngIf="detailTemplate?.templateRef && !isStacked"/>
<col *ngFor="let column of columnsToRender; trackBy: trackBy;"
[style.width]="getColumnWidth(column)"
[class.k-sorted]="isSorted(getColumnComponent(column))"/>
</ng-container>
`,
standalone: true,
imports: [NgFor, NgIf]
}]
}], ctorParameters: function () { return [{ type: i1.ContextService }]; }, propDecorators: { columns: [{
type: Input
}], groups: [{
type: Input
}], detailTemplate: [{
type: Input
}], sort: [{
type: Input
}] } });