pub struct Table { /* private fields */ }Expand description
A widget that displays a table with configurable column idths, optional header and scrollable row content. A widget that displays a table with configurable column widths, optional header and scrollable row content.
Each cell is represented by an Element, so cell can be any widget.
Layout of the cells is controlled by per-column widths and optional spacing
between columns.
§Example
let rows = get_people();
let widths = [Unit::Fill(3), Unit::Fill(1), Unit::Fill(3)];
let state = Rc::new(RefCell::new(TableState::new(0).selected(1)));
let table = Table::new(rows, widths, state)
.header(vec!["Name", "Age", "Email"])
.header_separator(BorderType::Double)
.column_spacing(2);
let mut term = Term::default();
term.render(table)?;Implementations§
Source§impl Table
impl Table
Sourcepub fn new<R, W>(rows: R, widths: W, state: Rc<RefCell<TableState>>) -> Self
pub fn new<R, W>(rows: R, widths: W, state: Rc<RefCell<TableState>>) -> Self
Creates new Table with given rows and columns widths
Sourcepub fn header_separator(self, separator: BorderType) -> Self
pub fn header_separator(self, separator: BorderType) -> Self
Sets the header separator of the Table
Sourcepub fn selected_row_style<S>(self, style: S) -> Self
pub fn selected_row_style<S>(self, style: S) -> Self
Sets the selected row style
Sourcepub fn selected_column_style<S>(self, style: S) -> Self
pub fn selected_column_style<S>(self, style: S) -> Self
Sets the selected column style
Sourcepub fn selected_cell_style<S>(self, style: S) -> Self
pub fn selected_cell_style<S>(self, style: S) -> Self
Sets the selected cell style
Sourcepub fn column_spacing(self, space: usize) -> Self
pub fn column_spacing(self, space: usize) -> Self
Sets the column spacing of the Table
Sourcepub fn auto_scroll(self) -> Self
pub fn auto_scroll(self) -> Self
Enables automatic scrolling to ensure the selected item is visible.
Sourcepub fn force_scrollbar(self) -> Self
pub fn force_scrollbar(self) -> Self
Forces scrollbar to be always visible. By default the scrollbar hides when the content doesn’t overflow.
Trait Implementations§
Source§impl Widget for Table
impl Widget for Table
Source§fn height(&self, size: &Vec2) -> usize
fn height(&self, size: &Vec2) -> usize
Widget based on the width of the given
size.