Learn R Programming

basictabler (version 0.3.1)

TableStyles: A class that defines a collection of styles.

Description

The TableStyles class defines all of the base styles needed to style/theme a table. It also defines the names of the styles that are used for styling the different parts of the table.

Arguments

Value

Object of R6Class with properties and methods that define styles/a theme for a table.

Format

R6Class object.

Fields

parentTable

Owning table.

themeName

The name of the theme.

allowExternalStyles

Enables 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

Documentation

For more complete explanations and examples please see the extensive vignettes supplied with this package.

new(...)

Create a new set of styles, specifying the field values documented above.

isExistingStyle(styleName)

Check whether the specified style exists.

getStyle(styleName)

Get the specified style.

addStyle(styleName, declarations)

Add a new style to the collection of styles.

copyStyle(styleName, newStyleName)

Create a copy of a style with the specified name.

asCSSRule(styleName, selector)

Get a style definition in the form of a CSS rule.

asNamedCSSStyle(styleName, styleNamePrefix)

Get a style definition in the form of a named CSS style.

asList()

Get a list representation of the styles.

asJSON()

Get a JSON representation of the styles.

asString()

Get a text representation of the styles.

Examples

Run this code
# NOT RUN {
# 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"
  ))
# }

Run the code above in your browser using DataLab