1 import {Component, Input, OnInit, Host, TemplateRef} from '@angular/core';
2 import {GridToolbarButton} from './grid';
3 import {GridComponent} from './grid.component';
6 selector: 'eg-grid-toolbar-button',
7 template: '<ng-template></ng-template>'
10 export class GridToolbarButtonComponent implements OnInit {
12 // Note most input fields should match class fields for GridColumn
13 @Input() label: string;
14 @Input() action: () => any;
16 @Input() set disabled(d: boolean) {
17 // Support asynchronous disabled values by appling directly
18 // to our button object as values arrive.
20 this.button.disabled = d;
24 button: GridToolbarButton;
26 // get a reference to our container grid.
27 constructor(@Host() private grid: GridComponent) {
28 this.button = new GridToolbarButton();
34 console.warn('GridToolbarButtonComponent needs a [grid]');
38 this.button.label = this.label;
39 this.button.action = this.action;
40 this.grid.context.toolbarButtons.push(this.button);