UNPKG

@progress/kendo-angular-grid

Version:

Kendo UI Grid for Angular - high performance data grid with paging, filtering, virtualization, CRUD, and more.

62 lines (61 loc) 2.94 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Directive, TemplateRef, Optional, Input } from '@angular/core'; import { GridConfigurationErrorMessages } from '../../common/error-messages'; import * as i0 from "@angular/core"; /** * Represents the detail template of the Grid ([more information and examples]({% slug detailrowtemplate_grid %})). * Nest an `<ng-template>` tag with the `kendoGridDetailTemplate` directive inside a `<kendo-grid>` tag to define the detail template. * * @example * ```html * <kendo-grid [data]="data" selectable="true" style="height: 160px"> * <kendo-grid-column field="ProductName"></kendo-grid-column> * <ng-template kendoGridDetailTemplate let-dataItem> * @if (dataItem.Category) { * <div> * <header>{{dataItem.Category?.CategoryName}}</header> * <span>{{dataItem.Category?.Description}}</span> * </div> * } * </ng-template> * </kendo-grid> * ``` * */ export class DetailTemplateDirective { templateRef; /** * Sets a function to decide if the detail row and the **Expand** or **Collapse** button display for a data item. * The function receives the data item and its index. */ set showIf(fn) { if (typeof fn !== 'function') { throw new Error(GridConfigurationErrorMessages.functionType('showIf', fn)); } this._condition = fn; } get showIf() { return this._condition; } constructor(templateRef) { this.templateRef = templateRef; } _condition = () => true; static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DetailTemplateDirective, deps: [{ token: i0.TemplateRef, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: DetailTemplateDirective, isStandalone: true, selector: "[kendoGridDetailTemplate]", inputs: { showIf: ["kendoGridDetailTemplateShowIf", "showIf"] }, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: DetailTemplateDirective, decorators: [{ type: Directive, args: [{ selector: '[kendoGridDetailTemplate]', standalone: true }] }], ctorParameters: () => [{ type: i0.TemplateRef, decorators: [{ type: Optional }] }], propDecorators: { showIf: [{ type: Input, args: ["kendoGridDetailTemplateShowIf"] }] } });