The `TableStyles` class defines all of the base styles needed to style/theme a table. It defines the names of the styles that are used for styling the different parts of the table.
R6Class
object.
count
The number of styles in this styles collection.
theme
The name of the theme.
styles
The collection of `TableStyle` objects in this styles collection.
allowExternalStyles
Enable integration scenarios where an external system is supplying the CSS definitions.
tableStyle
The name of the style for the HTML table element.
rootStyle
The name of the style for the HTML cell at the top left of the table (when both row and column headers are displayed).
rowHeaderStyle
The name of the style for the row headers in the table.
colHeaderStyle
The name of the style for the column headers in the table.
cellStyle
The name of the cell style for the non-total cells in the body of the table.
totalStyle
The name of the cell style for the total cells in the table.
new()
Create a new `TableStyles` object.
TableStyles$new(parentTable, themeName = NULL, allowExternalStyles = FALSE)
parentTable
Owning table.
themeName
The name of the theme.
allowExternalStyles
Enable integration scenarios where an external system is supplying the CSS definitions.
No return value.
isExistingStyle()
Check whether a style with the specified name exists in the collection.
TableStyles$isExistingStyle(styleName = NULL)
styleName
The style name.
`TRUE` if a style with the specified name exists, `FALSE` otherwise.
getStyle()
Retrieve a style with the specified name from the collection.
TableStyles$getStyle(styleName = NULL)
styleName
The style name.
A `TableStyle` object if a style with the specified name exists in the collection, an error is raised otherwise.
addStyle()
Add a new style to the collection of styles.
TableStyles$addStyle(styleName = NULL, declarations = NULL)
styleName
The style name of the new style.
declarations
A list containing CSS style declarations. Example: `declarations = list(font="...", color="...")`
The newly created `TableStyle` object.
copyStyle()
Create a copy of an exist style.
TableStyles$copyStyle(styleName = NULL, newStyleName = NULL)
styleName
The style name of the style to copy.
newStyleName
The name of the new style.
The newly created `TableStyle` object.
asCSSRule()
Generate a CSS style rule from the specified table style.
TableStyles$asCSSRule(styleName = NULL, selector = NULL)
styleName
The style name.
selector
The CSS selector name. Default value `NULL`.
The CSS style rule, e.g. text-align: center; color: red;
asNamedCSSStyle()
Generate a named CSS style from the specified table style.
TableStyles$asNamedCSSStyle(styleName = NULL, styleNamePrefix = NULL)
styleName
The style name.
styleNamePrefix
A character variable specifying a prefix for all named CSS styles, to avoid style name collisions where multiple tables exist.
The CSS style rule, e.g. cell text-align: center; color: red;
asList()
Return the contents of this object as a list for debugging.
TableStyles$asList()
A list of various object properties.
asJSON()
Return the contents of this object as JSON for debugging.
TableStyles$asJSON()
A JSON representation of various object properties.
asString()
Return the contents of this object as a string for debugging.
TableStyles$asString(seperator = ", ")
seperator
Delimiter used to combine multiple values into a string.
A character representation of various object properties.
clone()
The objects of this class are cloneable with this method.
TableStyles$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Creating styles is part of defining a theme for a table. # Multiple styles must be created for each theme. # The example below shows how to create one style. # For an example of creating a full theme please # see the Styling vignette. tbl <- BasicTable$new() # ... TableStyles <- TableStyles$new(tbl, themeName="compact") TableStyles$addStyle(styleName="MyNewStyle", list( font="0.75em arial", padding="2px", border="1px solid lightgray", "vertical-align"="middle", "text-align"="center", "font-weight"="bold", "background-color"="#F2F2F2" ))