NumericCellRenderer
class NumericCellRenderer implements RenderCellInterface, FormatterAwareInterface (View source)
Create a formatter to add commas to numeric data.
Example:
Value
2,384
143,894 23 98,538
This formatter may also be re-used for other purposes where right-justified data is desired by simply making a subclass. See method comments below.
Usage:
return (new RowsOfFields($data))->addRenderer(
new NumericCellRenderer($data, ['value'])
);
Traits
Properties
protected | $formatter | from FormatterAwareTrait | |
protected | $data | ||
protected | $renderedColumns | ||
protected | $widths |
Methods
NumericCellRenderer constructor
Right-justify the cell data.
Determine if this is a column that should be formatted.
Ignore cell data that should not be formatted.
Format the cell data.
This formatter only works with columns whose columns are strings.
Get the cached column width for the provided key.
Using the cached table data, calculate the largest width for the data in the table for use when right-justifying.
Details
setFormatter(FormatterInterface $formatter)
No description
getFormatter()
No description
isHumanReadable()
No description
__construct($data, $renderedColumns)
NumericCellRenderer constructor
mixed
renderCell(string $key, mixed $cellData, FormatterOptions $options, array $rowData)
No description
protected
justifyCellData($key, $cellData = "")
Right-justify the cell data.
protected
isRenderedFormat(FormatterOptions $options)
Determine if this format is to be formatted.
protected
isRenderedColumn($key)
Determine if this is a column that should be formatted.
protected
isRenderedData($cellData)
Ignore cell data that should not be formatted.
protected
formatCellData($cellData)
Format the cell data.
protected
convertCellDataToString($cellData)
This formatter only works with columns whose columns are strings.
To use this formatter for another purpose, override this method to ensure that the cell data is a string before it is formatted.
protected
columnWidth($key)
Get the cached column width for the provided key.
protected
calculateColumnWidth($key)
Using the cached table data, calculate the largest width for the data in the table for use when right-justifying.