1 import {Component, Input, OnInit, Host, Output, EventEmitter} from '@angular/core';
2 import {GridToolbarCheckbox} from './grid';
3 import {GridComponent} from './grid.component';
6 selector: 'eg-grid-toolbar-checkbox',
7 template: '<ng-template></ng-template>'
10 export class GridToolbarCheckboxComponent implements OnInit {
12 // Note most input fields should match class fields for GridColumn
13 @Input() label: string;
15 // Set the render time value.
16 // This does NOT fire the onChange handler.
17 @Input() initialValue: boolean;
19 // This is an input instead of an Output because the handler is
20 // passed off to the grid context for maintenance -- events
21 // are not fired directly from this component.
22 @Output() onChange: EventEmitter<boolean>;
24 // get a reference to our container grid.
25 constructor(@Host() private grid: GridComponent) {
26 this.onChange = new EventEmitter<boolean>();
32 console.warn('GridToolbarCheckboxComponent needs a [grid]');
36 const cb = new GridToolbarCheckbox();
37 cb.label = this.label;
38 cb.onChange = this.onChange;
39 cb.isChecked = this.initialValue;
41 this.grid.context.toolbarCheckboxes.push(cb);