I'm using custom directives to configure defaults for grid columns across the entire apps in a unified way.
For example there is a CurrencyColumnDirective which configures the currency format and adds a CSS class for right alignment:
import {Directive} from '@angular/core';
import {ColumnComponent} from '@progress/kendo-angular-grid';
@Directive({selector: '[appCurrencyColumn]'})
export class CurrencyColumnDirective {
constructor(private column: ColumnComponent) {
column.format = '{0:c}';
column.cssClass = 'app-ta-r';
}
}
It works perfectly when used like this:
<kendo-grid-column field="unitPrice" title="Unit Price" appCurrencyColumn></kendo-grid-column>
Here is a Plunker with a demo: https://plnkr.co/edit/UyXcqL8zzwXEwiQb0yGV?p=preview
Unfortunately the same approach does not work for CheckboxColumnComponent as it is not exported in module @progress/kendo-angular-grid although it is part of the public API.
It does work with JIT in the devserver (i.e. ng serve) when I use deep import {CheckboxColumnComponent} from '@progress/kendo-angular-grid/dist/es/columns/checkbox-column.component'; like this:
import {Directive} from '@angular/core';
import {CheckboxColumnComponent} from '@progress/kendo-angular-grid/dist/es/columns/checkbox-column.component';
@Directive({selector: 'kendo-grid-checkbox-column'})
export class CheckboxColumnDirective {
constructor(private column: CheckboxColumnComponent) {
column.width = 30;
column.resizable = false;
column.showSelectAll = true;
}
}
Although working in dev mode, it breaks AOT compilation for production (i.e. ng build --prod) with the following error:
ERROR in : Can't resolve all parameters for CheckboxColumnDirective in /Users/me/myapp/src/app/directives/grid/checkbox-column.directive.ts: (?).
__Environment:__
@progress/[email protected]
@angular/[email protected]
@angular/*@5.2.6
[email protected]
node 8.9.4
Mac OS 10.13.3
@akloeber Thank you for the report.
The fix is available in the dev build.
@rusev I can confirm that it works with the dev build (checked with @progress/[email protected]).
Most helpful comment
@rusev I can confirm that it works with the dev build (checked with
@progress/[email protected]).