pub struct TableState {
pub headers: Vec<String>,
pub rows: Vec<Vec<String>>,
pub selected: usize,
/* private fields */
}Expand description
State for a data table widget.
Pass a mutable reference to Context::table each frame. Up/Down arrow
keys move the row selection when the widget is focused. Column widths are
computed automatically from header and cell content.
Fields§
§headers: Vec<String>Column header labels.
rows: Vec<Vec<String>>Table rows, each a Vec of cell strings.
selected: usizeIndex of the currently selected row.
Implementations§
Source§impl TableState
impl TableState
Sourcepub fn new(
headers: Vec<impl Into<String>>,
rows: Vec<Vec<impl Into<String>>>,
) -> Self
pub fn new( headers: Vec<impl Into<String>>, rows: Vec<Vec<impl Into<String>>>, ) -> Self
Create a table with headers and rows. Column widths are computed immediately.
Sourcepub fn set_rows(&mut self, rows: Vec<Vec<impl Into<String>>>)
pub fn set_rows(&mut self, rows: Vec<Vec<impl Into<String>>>)
Replace all rows, preserving the selection index if possible.
If the current selection is beyond the new row count, it is clamped to the last row.
Sourcepub fn selected_row(&self) -> Option<&[String]>
pub fn selected_row(&self) -> Option<&[String]>
Get the currently selected row data, or None if the table is empty.
Auto Trait Implementations§
impl Freeze for TableState
impl RefUnwindSafe for TableState
impl Send for TableState
impl Sync for TableState
impl Unpin for TableState
impl UnsafeUnpin for TableState
impl UnwindSafe for TableState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more