You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
import {ICellRendererAngularComp} from 'ag-grid-angular';
|
|
import {Component} from '@angular/core';
|
|
import {ICellRendererParams} from 'ag-grid-community';
|
|
import * as moment from 'moment';
|
|
|
|
@Component({
|
|
selector: 'editor-boolean-renderer',
|
|
template: `{{ display }}`,
|
|
})
|
|
export class BooleanRendererComponent implements ICellRendererAngularComp {
|
|
public params: ICellRendererParams;
|
|
public emptyValue = '';
|
|
public trueValue = 'True';
|
|
public falseValue = 'False';
|
|
|
|
agInit(params: ICellRendererParams): void {
|
|
this.params = params;
|
|
// @ts-ignore
|
|
const labelType = params.colDef.additionalData.labelType.split('_').map(x => x.charAt(0).toUpperCase() + x.slice(1));
|
|
this.trueValue = labelType[0];
|
|
this.falseValue = labelType[1];
|
|
}
|
|
|
|
public get display() {
|
|
if ( this.params.value === true ) {
|
|
return this.trueValue;
|
|
} else if ( this.params.value === false ) {
|
|
return this.falseValue;
|
|
} else {
|
|
return this.emptyValue;
|
|
}
|
|
}
|
|
|
|
refresh(params: any): boolean {
|
|
return false;
|
|
}
|
|
}
|