@progress/kendo-angular-treelist
Version:
Kendo UI TreeList for Angular - Display hierarchical data in an Angular tree grid view that supports sorting, filtering, paging, and much more.
87 lines (86 loc) • 4.62 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, isDevMode } from '@angular/core';
import { maxWidthIcon } from '@progress/kendo-svg-icons';
import { ContextService } from '../common/provider.service';
import { ColumnMenuItemBase } from './column-menu-item-base';
import { autoSizeColumn } from './utils';
import { ColumnMenuItemComponent } from './column-menu-item.component';
import { ColumnMenuErrorMessages } from '../common/error-messages';
import * as i0 from "@angular/core";
import * as i1 from "../common/provider.service";
/**
* Represents the Kendo UI for Angular TreeList column-menu item for resizing a specified column to fit the header or cell content without wrapping. [See example](slug:columnmenu_treelist#toc-customizing-the-content).
*
* Place this component inside a [`ColumnMenuTemplate`]({% slug api_treelist_columnmenutemplatedirective %}) directive to enable the feature.
* Set the [`ColumnMenuService`]({% slug api_treelist_columnmenuservice %}) and `column` inputs using the values passed by the template.
*
* @example
* ```html
* <kendo-treelist [columnMenu]="true" ...>
* <ng-template kendoTreeListColumnMenuTemplate let-service="service" let-column="column">
* <kendo-treelist-columnmenu-autosize-column [column]="column" [service]="service">
* </kendo-treelist-columnmenu-autosize-column>
* </ng-template>
* </kendo-treelist>
* ```
*/
export class ColumnMenuAutoSizeColumnComponent extends ColumnMenuItemBase {
ctx;
/**
* The TreeList column instance to resize with the auto size column option.
*/
column;
maxWidthIcon = maxWidthIcon;
constructor(ctx) {
super();
this.ctx = ctx;
}
ngOnInit() {
const isVirtualColumns = this.ctx.treelist.columnMenuTemplate && this.ctx.treelist.virtualColumns;
if (isVirtualColumns && isDevMode()) {
console.warn(ColumnMenuErrorMessages.autoSizeColumn);
}
}
/**
* Resizes the specified column to the minimum possible width so that it fits the widest header or cell content without wrapping.
*/
autoSizeColumn() {
autoSizeColumn(this.ctx.treelist, this.service, this.column);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColumnMenuAutoSizeColumnComponent, deps: [{ token: i1.ContextService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ColumnMenuAutoSizeColumnComponent, isStandalone: true, selector: "kendo-treelist-columnmenu-autosize-column", inputs: { column: "column" }, usesInheritance: true, ngImport: i0, template: `
(!this.ctx.treelist.virtualColumns) {
<kendo-treelist-columnmenu-item
class="k-grid-columnmenu-autosize-column"
[text]="ctx.localization.get('autosizeThisColumn')"
icon="max-width"
[svgIcon]="maxWidthIcon"
(itemClick)="autoSizeColumn()"
></kendo-treelist-columnmenu-item>
}
`, isInline: true, dependencies: [{ kind: "component", type: ColumnMenuItemComponent, selector: "kendo-treelist-columnmenu-item", inputs: ["icon", "svgIcon", "text", "selected", "disabled", "expanded", "service"], outputs: ["itemClick", "expand", "collapse"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ColumnMenuAutoSizeColumnComponent, decorators: [{
type: Component,
args: [{
selector: 'kendo-treelist-columnmenu-autosize-column',
template: `
(!this.ctx.treelist.virtualColumns) {
<kendo-treelist-columnmenu-item
class="k-grid-columnmenu-autosize-column"
[text]="ctx.localization.get('autosizeThisColumn')"
icon="max-width"
[svgIcon]="maxWidthIcon"
(itemClick)="autoSizeColumn()"
></kendo-treelist-columnmenu-item>
}
`,
standalone: true,
imports: [ColumnMenuItemComponent]
}]
}], ctorParameters: () => [{ type: i1.ContextService }], propDecorators: { column: [{
type: Input
}] } });