OBaseTableCellRenderer

Description

All cell renderers in OntimizeWeb extend the OBaseTableCellRenderer class. This class provides a set of methods and properties by all the cell renderers components. This methods and attributes are explained on the API section of this page.

Below we will show an example of the custom cell renderer.

Example

    import { Component, Injector, TemplateRef, ViewChild } from '@angular/core';
    import { OBaseTableCellRenderer, OCurrencyPipe } from 'ontimize-web-ngx';

    @Component({
    selector: 'o-table-column-renderer-balance',
    templateUrl: './o-table-column-renderer-balance.component.html',
    host: { 'o-mat-column-currency': 'true' }
    })
    export class OTableColumnRendererBalanceComponent extends OBaseTableCellRenderer {

    @ViewChild('templateref', { read: TemplateRef }) public templateref: TemplateRef<any>;

    constructor(protected injector: Injector) {
        super(injector);
        this.setComponentPipe();
    }

    setComponentPipe() {
        this.componentPipe = new OCurrencyPipe(this.injector);
    }

    ngOnInit() {
        this.pipeArguments = {
        currencySimbol: '€',
        currencySymbolPosition: 'right',
        decimalDigits: 2,
        decimalSeparator: ',',
        grouping: true,
        thousandSeparator: '.'
        };
    }

    getCellData(value: any) {
        let parsedValue: string;
        if (this.componentPipe && typeof this.pipeArguments !== 'undefined' && value !== undefined) {
        parsedValue = this.componentPipe.transform(value, this.pipeArguments);
        }
        return parsedValue;
    }

}

Class: OBaseTableCellRenderer

Properties

Name Type Description

column

property

Name of the column

table

property

Reference to the component OTableComponent

tableColumn

property

Reference to the component OTableColumnComponent

getCellData(cellvalue,rowvalue)

method

This default method returns the value of the column as a string. This method is used to obtain the value of the column in the exports or filtering, so that if you want to customize the value of the column you must overwrite it.

Updated: