Last active
September 29, 2022 17:33
-
-
Save fergusonjason/69bc57660237977b03c8dde97b813709 to your computer and use it in GitHub Desktop.
Angular Kendo Column Date Formatter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, OnInit, Input } from '@angular/core'; | |
import { ColumnComponent } from '@progress/kendo-angular-grid'; | |
// Usage: | |
// | |
// <kendo-grid-column field="fieldname" title="Field Title" kendo-column-date-format="dd/MM/yyyy"></kendo-grid-column> | |
// | |
@Directive({ | |
selector: '[kendo-column-date-format]' | |
}) | |
export class ColumnDateFormatDirective implements OnInit{ | |
@Input('kendo-column-date-format') | |
kendoColumnDateFormat : string | undefined; | |
constructor(private element: ColumnComponent) { } | |
ngOnInit() { | |
if (this.kendoColumnDateFormat !== undefined) { | |
this.element.format = `{0:${this.kendoColumnDateFormat}}`; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment