Skip to content

Instantly share code, notes, and snippets.

@fergusonjason
Last active September 29, 2022 17:33
Show Gist options
  • Save fergusonjason/69bc57660237977b03c8dde97b813709 to your computer and use it in GitHub Desktop.
Save fergusonjason/69bc57660237977b03c8dde97b813709 to your computer and use it in GitHub Desktop.
Angular Kendo Column Date Formatter
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