pub struct Table<'a> { /* private fields */ }Expand description
A widget to display data in a table.
Implementations§
Source§impl<'a> Table<'a>
impl<'a> Table<'a>
Sourcepub fn new(
rows: impl IntoIterator<Item = Row>,
widths: impl IntoIterator<Item = Constraint>,
) -> Self
pub fn new( rows: impl IntoIterator<Item = Row>, widths: impl IntoIterator<Item = Constraint>, ) -> Self
Create a new table with the given rows and column width constraints.
Sourcepub fn with_column_spec(self, col: usize, spec: ColumnSpec) -> Self
pub fn with_column_spec(self, col: usize, spec: ColumnSpec) -> Self
Set the specification for a column by index.
Sourcepub fn with_column_truncation(self, col: usize, truncation: Truncate) -> Self
pub fn with_column_truncation(self, col: usize, truncation: Truncate) -> Self
Set the truncation mode for a column by index.
Sourcepub fn with_column_alignment(self, col: usize, alignment: Alignment) -> Self
pub fn with_column_alignment(self, col: usize, alignment: Alignment) -> Self
Set the text alignment for a column by index.
Sourcepub fn data_hash(self, hash: u64) -> Self
pub fn data_hash(self, hash: u64) -> Self
Set an explicit data hash to enable caching of filtered and sorted indices.
This is highly recommended for large tables. When provided, the table widget
will cache the result of filtering and sorting in the TableState, skipping
expensive O(N) re-evaluation on frames where the hash, filter, and sort
parameters have not changed.
Sourcepub fn highlight_style(self, style: Style) -> Self
pub fn highlight_style(self, style: Style) -> Self
Set the style for the selected row.
Sourcepub fn theme(self, theme: TableTheme) -> Self
pub fn theme(self, theme: TableTheme) -> Self
Set the table theme (base/states/effects).
Sourcepub const fn table_theme(&self) -> &TableTheme
pub const fn table_theme(&self) -> &TableTheme
Get a reference to the table theme.
Sourcepub fn with_stylesheet(self, sheet: &StyleSheet) -> Self
pub fn with_stylesheet(self, sheet: &StyleSheet) -> Self
Apply styles from a StyleSheet using the default prefix "table".
Looks up styles with names like "table.border", "table.header", "table.row",
"table.row_alt", "table.row_selected", "table.row_hover", and "table.divider".
Only roles defined in the stylesheet will override the current theme’s styles.
Sourcepub fn with_stylesheet_prefix(self, sheet: &StyleSheet, prefix: &str) -> Self
pub fn with_stylesheet_prefix(self, sheet: &StyleSheet, prefix: &str) -> Self
Apply styles from a StyleSheet using a custom prefix.
For each standard role (border, header, row, row_alt, row_selected,
row_hover, divider), if {prefix}.{role} is defined in the stylesheet,
it replaces that style in the table’s theme.
Sourcepub fn theme_phase(self, phase: f32) -> Self
pub fn theme_phase(self, phase: f32) -> Self
Set the explicit animation phase for theme effects.
Phase is deterministic and should be supplied by the caller (e.g. from tick count).
Sourcepub fn column_spacing(self, spacing: u16) -> Self
pub fn column_spacing(self, spacing: u16) -> Self
Set the spacing between columns, overriding TableTheme::column_gap.
Sourcepub fn cell_padding(self, padding: u8) -> Self
pub fn cell_padding(self, padding: u8) -> Self
Set horizontal cell padding (in cells on both left and right of each column),
overriding TableTheme::padding.
Sourcepub fn use_theme_padding(self, enabled: bool) -> Self
pub fn use_theme_padding(self, enabled: bool) -> Self
Opt in to applying TableTheme::padding as horizontal cell inset on each column.