Interface CellRendererIf

Decides how a cell looks – the value stays the same for sorting, filtering, copy and Excel export. Assign it per column and area (columnDef.rendererMap.body = …, or bodyRenderer in ColumnDef.create) or return it from AreaModelIf.getCellRenderer.

Renderers are called only for visible cells, on every repaint – keep them cheap.

Example

class StatusBadgeRenderer implements CellRendererIf {
render(cellDiv: HTMLDivElement, rowIndex: number, columnIndex: number, areaIdent: AreaIdent,
areaModel: AreaModelIf, cellValue: string, dom: DomServiceIf): RendererCleanupFnType | undefined {
const badge = dom.createElement<HTMLSpanElement>("span");
dom.addClass(badge, `status-${cellValue}`);
badge.textContent = cellValue;
dom.appendChild(cellDiv, badge);
return undefined; // or a cleanup function (listeners, timers …)
}
}
columnDefs[9].rendererMap.body = new StatusBadgeRenderer();

See

Training: Cell renderers, Framework components as cells

Hierarchy

  • CellRendererIf

Implemented by

Methods

Methods

  • Fills the (empty) cell element.

    Parameters

    • cellDiv: HTMLDivElement

      the cell element, already positioned and sized

    • rowIndex: number

      row in the area (as displayed)

    • columnIndex: number

      column index (west + center + east)

    • areaIdent: AreaIdent

      "header", "body" or "footer"

    • areaModel: AreaModelIf

      the model of this area (e.g. for getRowByIndex(rowIndex))

    • cellValue: any

      the value of the cell (areaModel.getValueAt(rowIndex, columnIndex))

    • domService: DomServiceIf

      create and change elements through it (works with Angular's Renderer2, too)

    Returns undefined | Function

    optionally a cleanup function, called before the cell is drawn again