| sprinkle_fixed_header {pixiedust} | R Documentation |
Assign a Fixed Header to an HTML Table
Description
Long tables to be displayed on-screen may benefit by keeping the header fixed in position while scrolling through the body of the table. This allows the user to maintain visual contact between the column name and the data.
Usage
sprinkle_fixed_header(
x,
fixed_header = TRUE,
include_fixed_header_css = TRUE,
fixed_header_class_name = "pixie-fixed",
scroll_body_height = 300,
scroll_body_height_units = "px",
scroll_body_background_color = "white",
fixed_header_height = 20,
fixed_header_height_units = "px",
fixed_header_text_height = fixed_header_height/2,
fixed_header_text_height_units = "px",
fixed_header_background_color = "white",
...
)
## Default S3 method:
sprinkle_fixed_header(
x,
fixed_header = TRUE,
include_fixed_header_css = TRUE,
fixed_header_class_name = "pixie-fixed",
scroll_body_height = 300,
scroll_body_height_units = "px",
scroll_body_background_color = "white",
fixed_header_height = 20,
fixed_header_height_units = "px",
fixed_header_text_height = fixed_header_height/2,
fixed_header_text_height_units = "px",
fixed_header_background_color = "white",
...
)
## S3 method for class 'dust_list'
sprinkle_fixed_header(
x,
fixed_header = TRUE,
include_fixed_header_css = TRUE,
fixed_header_class_name = "pixie-fixed",
scroll_body_height = 300,
scroll_body_height_units = "px",
scroll_body_background_color = "white",
fixed_header_height = 20,
fixed_header_height_units = "px",
fixed_header_text_height = fixed_header_height/2,
fixed_header_text_height_units = "px",
fixed_header_background_color = "white",
...
)
Arguments
x |
An object of class |
fixed_header |
|
include_fixed_header_css |
|
fixed_header_class_name |
|
scroll_body_height |
|
scroll_body_height_units |
|
scroll_body_background_color |
|
fixed_header_height |
|
fixed_header_height_units |
|
fixed_header_text_height |
|
fixed_header_text_height_units |
|
fixed_header_background_color |
|
... |
Arguments to pass to other methods. |
Details
CSS doesn't make this kind of table natural. The solution to
generate the fixed headers used by pixiedust is probably not the
best solution in terms of CSS design. It is, however, the most conducive
to generating dynamically on the fly.
The fixed header table requires nesting several HTML elements.
a
divtag is used to control the alignment of the tablea
sectiontag is used to set up the header row that remains fixed.a
divthat sets the height of the scrollable bodythe
tabletag establishes the actual table.The
thtags inside the table are set to full transparency and the content of the headers is duplicated in adivwithin thethtag to display the content.
To accomplish these tasks, some CSS is exported with the table and placed in the document immediately before the table. Read further to understand the conflicts that may arise if you are using custom CSS specifications in your documents.
Avoiding CSS Conflicts
Because of all of the shenanigans involved, exporting the CSS with the tables
may result in conflicts with your custom CSS. Most importantly, any CSS
you have applied to the th or td tags may be overwritten.
If you are using custom CSS, you may want to consider using
include_fixed_header_css = FALSE and then utilizing
fixed_header_css to generate CSS you can include in your
CSS file to provide the fixed headers. The code generated by
fixed_header_css ought to be placed before your definitions for
td and th.
To get the same header design in the fixed table, you will want to modify
the .th-pixie-fixed div definition in the CSS to match your desired
th definition.
The code produced by fixed_header_css will include comments where
there is potential for a CSS conflict.
Functional Requirements
Set the
fixed_headerelement of thedustobject correctly.Set the
include_fixed_header_csselement of thedustobject correctly.Set the
fixed_header_paramelement of thedustobject correctly.Cast an error if
xdoes not inherit classdustCast an error if
scroll_body_heightis notintegerish(1)Cast an error if
scroll_body_height_unitsis notcharacter(1)Cast an error if
scroll_body_background_coloris notcharacter(1)Cast an error if
scroll_body_background_coloris not a valid color.Cast an error if
fixed_header_heightis notintegerish(1)Cast an error if
fixed_header_height_unitsis notcharacter(1)Cast an error if
fixed_header_text_heightis notnumeric(1)Cast an error if
fixed_header_text_height_unitsis notcharacter(1)Cast an error if
fixed_header_background_coloris notcharacter(1)Cast an error if
fixed_header_background_coloris not a valid color.Cast an error if
include_fixed_header_cssis notlogical(1)Cast an error if
fixed_header_class_nameis notcharacter(1)