@progress/kendo-angular-grid
Version:
Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.
164 lines (163 loc) • 7.72 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, Output, EventEmitter, ChangeDetectorRef, ElementRef } from '@angular/core';
import { ColumnInfoService } from '../common/column-info.service';
import { ColumnMenuItemBase } from './column-menu-item-base';
import { columnsIcon } from '@progress/kendo-svg-icons';
import { ContextService } from '../common/provider.service';
import { ColumnListComponent } from './column-list.component';
import { ColumnMenuItemContentTemplateDirective } from './column-menu-item-content-template.directive';
import { ColumnMenuItemComponent } from './column-menu-item.component';
import * as i0 from "@angular/core";
import * as i1 from "../common/provider.service";
import * as i2 from "../common/column-info.service";
/**
* Represents the column-menu item for selecting columns in the Grid. [See example](slug:columnmenu_grid#toc-column-chooser-item).
*
* The component can be placed inside a [ColumnMenuTemplate]({% slug api_grid_columnmenutemplatedirective %}) directive.
* To register the component as a known column menu item, set the [ColumnMenuService]({% slug api_grid_columnmenuservice %}) that is passed by
* the template to the service input of the `kendo-grid-columnmenu-chooser` component. [See example](slug:columnmenu_grid#toc-customizing-the-content).
*
* @example
* ```html
* <kendo-grid [columnMenu]="true" ...>
* <ng-template kendoGridColumnMenuTemplate let-service="service">
* <kendo-grid-columnmenu-chooser [service]="service"> </kendo-grid-columnmenu-chooser>
* </ng-template>
* </kendo-grid>
* ```
*/
export class ColumnMenuChooserComponent extends ColumnMenuItemBase {
ctx;
columnInfoService;
changeDetector;
hostElement;
/**
* Fires when the content is expanded.
*/
expand = new EventEmitter();
/**
* Fires when the content is collapsed.
*/
collapse = new EventEmitter();
/**
* Specifies if the content is expanded.
* @default false
*/
expanded = false;
/**
* @hidden
*/
isLast = false;
/**
* @hidden
*/
actionsClass = 'k-actions k-actions-stretched k-actions-horizontal';
get columns() {
return this.columnInfoService.leafNamedColumns;
}
columnsIcon = columnsIcon;
constructor(ctx, columnInfoService, changeDetector, hostElement) {
super();
this.ctx = ctx;
this.columnInfoService = columnInfoService;
this.changeDetector = changeDetector;
this.hostElement = hostElement;
}
/**
* @hidden
*/
onApply(changed) {
this.close();
if (changed.length) {
this.changeDetector.markForCheck();
this.columnInfoService.changeVisibility(changed);
}
}
/**
* @hidden
*/
onCollapse() {
this.expanded = false;
if (this.isLast) {
this.service.menuTabbingService.lastFocusable = this.hostElement.nativeElement.querySelector('.k-columnmenu-item');
}
this.collapse.emit();
}
/**
* @hidden
*/
onExpand() {
this.expanded = true;
this.expand.emit();
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnMenuChooserComponent, deps: [{ token: i1.ContextService }, { token: i2.ColumnInfoService }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ColumnMenuChooserComponent, isStandalone: true, selector: "kendo-grid-columnmenu-chooser", inputs: { expanded: "expanded", isLast: "isLast" }, outputs: { expand: "expand", collapse: "collapse" }, usesInheritance: true, ngImport: i0, template: `
<kendo-grid-columnmenu-item
[text]="ctx.localization.get('columns')"
icon="columns"
[svgIcon]="columnsIcon"
[expanded]="expanded"
(collapse)="onCollapse()"
(expand)="onExpand()">
<ng-template kendoGridColumnMenuItemContentTemplate>
<kendo-grid-columnlist
[applyText]="ctx.localization.get('columnsApply')"
[resetText]="ctx.localization.get('columnsReset')"
[ariaLabel]="ctx.localization.get('columns')"
[columns]="columns"
[autoSync]="false"
[allowHideAll]="false"
[actionsClass]="actionsClass"
[isLast]="isLast"
[isExpanded]="expanded"
[service]="service"
(apply)="onApply($event)">
</kendo-grid-columnlist>
</ng-template>
</kendo-grid-columnmenu-item>
`, isInline: true, dependencies: [{ kind: "component", type: ColumnMenuItemComponent, selector: "kendo-grid-columnmenu-item", inputs: ["icon", "svgIcon", "text", "selected", "disabled", "expanded", "service"], outputs: ["itemClick", "expand", "collapse"] }, { kind: "directive", type: ColumnMenuItemContentTemplateDirective, selector: "[kendoGridColumnMenuItemContentTemplate]" }, { kind: "component", type: ColumnListComponent, selector: "kendo-grid-columnlist", inputs: ["columns", "autoSync", "ariaLabel", "allowHideAll", "applyText", "resetText", "actionsClass", "isLast", "isExpanded", "service"], outputs: ["reset", "apply", "columnChange"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ColumnMenuChooserComponent, decorators: [{
type: Component,
args: [{
selector: 'kendo-grid-columnmenu-chooser',
template: `
<kendo-grid-columnmenu-item
[text]="ctx.localization.get('columns')"
icon="columns"
[svgIcon]="columnsIcon"
[expanded]="expanded"
(collapse)="onCollapse()"
(expand)="onExpand()">
<ng-template kendoGridColumnMenuItemContentTemplate>
<kendo-grid-columnlist
[applyText]="ctx.localization.get('columnsApply')"
[resetText]="ctx.localization.get('columnsReset')"
[ariaLabel]="ctx.localization.get('columns')"
[columns]="columns"
[autoSync]="false"
[allowHideAll]="false"
[actionsClass]="actionsClass"
[isLast]="isLast"
[isExpanded]="expanded"
[service]="service"
(apply)="onApply($event)">
</kendo-grid-columnlist>
</ng-template>
</kendo-grid-columnmenu-item>
`,
standalone: true,
imports: [ColumnMenuItemComponent, ColumnMenuItemContentTemplateDirective, ColumnListComponent]
}]
}], ctorParameters: function () { return [{ type: i1.ContextService }, { type: i2.ColumnInfoService }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }]; }, propDecorators: { expand: [{
type: Output
}], collapse: [{
type: Output
}], expanded: [{
type: Input
}], isLast: [{
type: Input
}] } });