| TableStyles {basictabler} | R Documentation |
R6 class that defines a collection of styles.
Description
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.
Format
R6Class object.
Active bindings
countThe number of styles in this styles collection.
themeThe name of the theme.
stylesThe collection of 'TableStyle' objects in this styles collection.
allowExternalStylesEnable integration scenarios where an external system is supplying the CSS definitions.
tableStyleThe name of the style for the HTML table element.
rootStyleThe name of the style for the HTML cell at the top left of the table (when both row and column headers are displayed).
rowHeaderStyleThe name of the style for the row headers in the table.
colHeaderStyleThe name of the style for the column headers in the table.
cellStyleThe name of the cell style for the non-total cells in the body of the table.
totalStyleThe name of the cell style for the total cells in the table.
Methods
Public methods
Method new()
Create a new 'TableStyles' object.
Usage
TableStyles$new(parentTable, themeName = NULL, allowExternalStyles = FALSE)
Arguments
parentTableOwning table.
themeNameThe name of the theme.
allowExternalStylesEnable integration scenarios where an external system is supplying the CSS definitions.
Returns
No return value.
Method isExistingStyle()
Check whether a style with the specified name exists in the collection.
Usage
TableStyles$isExistingStyle(styleName = NULL)
Arguments
styleNameThe style name.
Returns
'TRUE' if a style with the specified name exists, 'FALSE' otherwise.
Method getStyle()
Retrieve a style with the specified name from the collection.
Usage
TableStyles$getStyle(styleName = NULL)
Arguments
styleNameThe style name.
Returns
A 'TableStyle' object if a style with the specified name exists in the collection, an error is raised otherwise.
Method addStyle()
Add a new style to the collection of styles.
Usage
TableStyles$addStyle(styleName = NULL, declarations = NULL)
Arguments
styleNameThe style name of the new style.
declarationsA list containing CSS style declarations. Example: 'declarations = list(font="...", color="...")'
Returns
The newly created 'TableStyle' object.
Method copyStyle()
Create a copy of an exist style.
Usage
TableStyles$copyStyle(styleName = NULL, newStyleName = NULL)
Arguments
styleNameThe style name of the style to copy.
newStyleNameThe name of the new style.
Returns
The newly created 'TableStyle' object.
Method asCSSRule()
Generate a CSS style rule from the specified table style.
Usage
TableStyles$asCSSRule(styleName = NULL, selector = NULL)
Arguments
styleNameThe style name.
selectorThe CSS selector name. Default value 'NULL'.
Returns
The CSS style rule, e.g. text-align: center; color: red;
Method asNamedCSSStyle()
Generate a named CSS style from the specified table style.
Usage
TableStyles$asNamedCSSStyle(styleName = NULL, styleNamePrefix = NULL)
Arguments
styleNameThe style name.
styleNamePrefixA character variable specifying a prefix for all named CSS styles, to avoid style name collisions where multiple tables exist.
Returns
The CSS style rule, e.g. cell text-align: center; color: red;
Method asList()
Return the contents of this object as a list for debugging.
Usage
TableStyles$asList()
Returns
A list of various object properties.
Method asJSON()
Return the contents of this object as JSON for debugging.
Usage
TableStyles$asJSON()
Returns
A JSON representation of various object properties.
Method asString()
Return the contents of this object as a string for debugging.
Usage
TableStyles$asString(seperator = ", ")
Arguments
seperatorDelimiter used to combine multiple values into a string.
Returns
A character representation of various object properties.
Method clone()
The objects of this class are cloneable with this method.
Usage
TableStyles$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
# 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"
))