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

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.

Methods

Public methods


Method new()

Create a new `TableStyles` object.

Usage

TableStyles$new(parentTable, themeName = NULL, allowExternalStyles = FALSE)

Arguments

parentTable

Owning table.

themeName

The name of the theme.

allowExternalStyles

Enable 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

styleName

The 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

styleName

The 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

styleName

The style name of the new style.

declarations

A 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

styleName

The style name of the style to copy.

newStyleName

The 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

styleName

The style name.

selector

The 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

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.

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

seperator

Delimiter 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

deep

Whether 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" ))