| TableCell {basictabler} | R Documentation |
R6 class that represents a cell in a table.
Description
The 'TableCell' class represents a cell in a table. Both header cells and body cells are represented by this class.
Format
R6Class object.
Active bindings
instanceIdAn integer value that uniquely identifies this cell. NB: This number is guaranteed to be unique within the table, but the method of generation of the values may change in future, so you are advised not to base any logic on specific values.
cellTypeOne of the following values that specifies the type of cell: root, rowHeader, columnHeader, cell, total. The cellType controls the default styling that is applied to the cell.
rowNumberThe row number of the cell. 1 = the first (i.e. top) data row.
columnNumberThe column number of the cell. 1 = the first (i.e. leftmost) data column.
visibleTRUE or FALSE to specify whether the cell is rendered.
rawValueThe original unformatted value.
formattedValueThe formatted value (i.e. normally of character data type).
asNBSPTRUE or FALSE to specify whether cells with no formatted value be output as html nbsp.
fValueOrNBSPFor internal use by the renderers only.
isMergedFor internal use by the renderers only.
isMergeRootFor internal use by the renderers only.
mergeIndexFor internal use by the renderers only.
baseStyleNameThe name of the style applied to this cell (a character value). The style must exist in the TableStyles object associated with the table.
styleA TableStyle object that can apply overrides to the base style for this cell.
Methods
Public methods
Method new()
Create a new 'TableCell' object.
Usage
TableCell$new( parentTable, rowNumber = NULL, columnNumber = NULL, cellType = "cell", visible = TRUE, rawValue = NULL, formattedValue = NULL, baseStyleName = NULL, styleDeclarations = NULL, asNBSP = FALSE )
Arguments
parentTableOwning table.
rowNumberThe row number of the cell. 1 = the first (i.e. top) data row.
columnNumberThe column number of the cell. 1 = the first (i.e. leftmost) data column.
cellTypeOne of the following values that specifies the type of cell: root, rowHeader, columnHeader, cell, total. The cellType controls the default styling that is applied to the cell.
visible'TRUE' or 'FALSE' to specify whether the cell is rendered.
rawValueThe original unformatted value.
formattedValueThe formatted value (i.e. normally of character data type).
baseStyleNameThe name of the style applied to this cell (a character value). The style must exist in the TableStyles object associated with the table.
styleDeclarationsA list containing CSS style declarations.
asNBSP'TRUE' or 'FALSE' to specify whether cells with no formatted value be output as html nbsp.
Returns
No return value.
Method updatePosition()
Set the cell location in the table. Mainly exists for internal use. Typically used after rows/columns/cells are inserted or deleted (which shifts other cells).
Usage
TableCell$updatePosition(rowNumber = NULL, columnNumber = NULL)
Arguments
rowNumberThe row number of the cell. 1 = the first (i.e. top) data row.
columnNumberThe column number of the cell. 1 = the first (i.e. leftmost) data column.
Returns
No return value.
Method getCopy()
Stub only (ignore).
Usage
TableCell$getCopy()
Returns
No return value.
Method asList()
Return the contents of this object as a list for debugging.
Usage
TableCell$asList()
Returns
A list of various object properties.
Method asJSON()
Return the contents of this object as JSON for debugging.
Usage
TableCell$asJSON()
Returns
A JSON representation of various object properties.
Method clone()
The objects of this class are cloneable with this method.
Usage
TableCell$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
# This class should only be created by using the functions in the table.
# It is not intended to be created by users outside of the table.
library(basictabler)
tbl <- qtbl(data.frame(a=1:2, b=3:4))
cell1 <- tbl$cells$setCell(r=4, c=1, cellType="cell", rawValue=5)
cell2 <- tbl$cells$setCell(r=4, c=2, cellType="cell", rawValue=6)
tbl$renderTable()