Skip to main content

Table

Struct Table 

Source
pub struct Table<T: 'static = (), K: 'static = ()> { /* private fields */ }
Expand description

A virtualised table: rows of cells under column headers, shown by the platform’s own table control.

ⓘ
Table::new(move || files.get(), |f| f.path.clone())
    .column(TableColumn::new("Name", |f: File| Text::new(f.name)).expand().sort_key(By::Name))
    .column(TableColumn::new("Size", |f: File| Text::new(f.size_text())).width(80).sort_key(By::Size))
    .sort(sort)                    // Signal<Sort<By>>: the column and order
    .selected(selected)            // Signal<Vec<K>>: the selected keys
    .on_activate(|path| open(path))

As in a List, only the rows the platform shows are mounted. A row is as high as its highest cell, or as the platform’s rows are, if they’re higher; a cell is as high as its content, where the platform places it in its row.

Rows are read by screen readers (and found by tests) as rows named by their cells’ text, and the cells as cells named by theirs.

The type’s defaults make Table alone name the widget, for Tweak<Table>.

Implementations§

Source§

impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> Table<T, K>

Source

pub fn new( each: impl IntoValue<Vec<T>>, key: impl Fn(&T) -> K + 'static, ) -> Table<T, K>

Source§

impl<T: 'static, K: 'static> Table<T, K>

Source

pub fn drag_files(self, file: impl Fn(&T) -> Option<PathBuf> + 'static) -> Self

Rows can be dragged out of the app, carrying the files their items stand for, as a List’s drag_files.

Source

pub fn column(self, column: TableColumn<T>) -> Self

Adds a column, after the others.

Source

pub fn columns(self, columns: impl IntoIterator<Item = TableColumn<T>>) -> Self

Adds columns, after the others.

Source

pub fn sort<S: PartialEq + Clone + 'static>(self, sort: Signal<Sort<S>>) -> Self

Binds how the table is sorted, both ways: its header shows it, and pressing a sortable column’s header sets it, as the platform sorts (the same column the other way round, another one ascending). The app sorts the data by it. Columns are sortable by their sort_keys, of this signal’s type.

Source

pub fn selected(self, selected: Signal<Vec<K>>) -> Self

Binds the selection, as the selected rows’ keys, both ways. Tables with a selection bound select one row at a time unless selection_mode says otherwise.

Source

pub fn selection_mode(self, mode: impl IntoValue<SelectionMode>) -> Self

How many rows can be selected, as a List’s selection_mode.

Source

pub fn list_style(self, style: ListStyle) -> Self

How the table sits in its surroundings, as a List’s list_style.

Source

pub fn on_activate(self, handler: impl Fn(K) + 'static) -> Self

Called with a row’s key when it’s activated: double-clicked, or Enter pressed on it.

Source

pub fn on_key( self, key: impl Into<Shortcut>, handler: impl Fn() + 'static, ) -> Self

Runs handler when key is pressed while the table, or a control inside it, has keyboard focus, and the focused control doesn’t use the key itself (the arrows, Home and End, typing to select, and what else the platform’s table takes): Space for a preview, Delete for Move to Trash. A key goes to the nearest node around the focused control that takes it. Nothing shows keys taken this way, so give the command a menu item or a button too, and pick the keys the platform’s own apps use (platform!).

ⓘ
Table::new(..).on_key(' ', preview)
Source

pub fn estimated_row_height(self, height: impl Into<Length>) -> Self

How high rows are likely to be, for platforms that size rows before they’re shown (AppKit). By default, the rows shown so far tell.

Source

pub fn handle(self, handle: ListHandle<K>) -> Self

Connects a ListHandle, to scroll the table from code.

Source

pub fn native(self, tweak: Tweak<Table>) -> Self

Raw platform settings: see Tweak. They run on the table view, not the scroll view around it.

Trait Implementations§

Source§

impl<T: 'static, K: 'static> ElementBuilder for Table<T, K>

Source§

fn element(&mut self) -> &mut Element

Source§

fn style(self, f: impl FnOnce(&mut Style)) -> Self

Escape hatch: edit the style directly (static).
Source§

fn style_with(self, f: impl Fn(&mut Style) + 'static) -> Self

Escape hatch: edit the style reactively. f re-runs whenever the signals it reads change, and must set every field it cares about.
Source§

fn width(self, value: impl IntoValue<Length>) -> Self

Source§

fn height(self, value: impl IntoValue<Length>) -> Self

Source§

fn min_width(self, value: impl IntoValue<Length>) -> Self

Source§

fn min_height(self, value: impl IntoValue<Length>) -> Self

Source§

fn max_width(self, value: impl IntoValue<Length>) -> Self

Source§

fn max_height(self, value: impl IntoValue<Length>) -> Self

Source§

fn aspect_ratio(self, value: impl IntoValue<f32>) -> Self

Source§

fn padding(self, value: impl IntoValue<Length>) -> Self

Source§

fn padding_x(self, value: impl IntoValue<Length>) -> Self

Source§

fn padding_y(self, value: impl IntoValue<Length>) -> Self

Source§

fn padding_start(self, value: impl IntoValue<Length>) -> Self

Source§

fn padding_end(self, value: impl IntoValue<Length>) -> Self

Source§

fn padding_top(self, value: impl IntoValue<Length>) -> Self

Source§

fn padding_bottom(self, value: impl IntoValue<Length>) -> Self

Source§

fn margin(self, value: impl IntoValue<Length>) -> Self

Source§

fn margin_x(self, value: impl IntoValue<Length>) -> Self

Source§

fn margin_y(self, value: impl IntoValue<Length>) -> Self

Source§

fn margin_start(self, value: impl IntoValue<Length>) -> Self

Source§

fn margin_end(self, value: impl IntoValue<Length>) -> Self

Source§

fn margin_top(self, value: impl IntoValue<Length>) -> Self

Source§

fn margin_bottom(self, value: impl IntoValue<Length>) -> Self

Source§

fn grow(self, value: impl IntoValue<f32>) -> Self

Source§

fn shrink(self, value: impl IntoValue<f32>) -> Self

Source§

fn basis(self, value: impl IntoValue<Length>) -> Self

Source§

fn align_self(self, value: impl IntoValue<Align>) -> Self

Source§

fn justify_self(self, value: impl IntoValue<Align>) -> Self

Alignment inside a grid cell along the inline axis.
Source§

fn top(self, value: impl IntoValue<Length>) -> Self

Inset from the top of the containing block (with absolute()).
Source§

fn bottom(self, value: impl IntoValue<Length>) -> Self

Source§

fn start(self, value: impl IntoValue<Length>) -> Self

Inset from the inline start (left in LTR, right in RTL).
Source§

fn end(self, value: impl IntoValue<Length>) -> Self

Source§

fn grid_column(self, value: impl IntoValue<GridPlacement>) -> Self

Source§

fn grid_row(self, value: impl IntoValue<GridPlacement>) -> Self

Source§

fn direction(self, value: impl IntoValue<TextDirection>) -> Self

Source§

fn hidden(self, value: impl IntoValue<bool>) -> Self

Not laid out, not visible, not focusable, not in the a11y tree. Un-hiding restores whatever display the node had.
Source§

fn size( self, width: impl IntoValue<Length>, height: impl IntoValue<Length>, ) -> Self

Source§

fn absolute(self) -> Self

Takes the node out of flow; position it with top/start/….
Source§

fn tooltip(self, text: impl IntoValue<String>) -> Self

A tooltip: text the platform shows, its own way, when the pointer rests on the widget, and assistive technology reads as its description. Empty: none.
Source§

fn context_menu(self, entries: impl MenuEntries) -> Self

A context menu: the platform shows it its own way, on a right-click, a long press or the menu key, and over children without one of their own. Takes items, separators and submenus, as a Menu does, with the same reactive titles, states and check marks: Read more
Source§

fn context_menu_with<E: MenuEntries>( self, entries: impl Fn() -> E + 'static, ) -> Self

A context menu built by entries, and built again whenever what it reads changes, as Menu::children_with builds its entries.
Source§

fn context_menu_on_open<E: MenuEntries>( self, entries: impl Fn() -> E + 'static, ) -> Self

A context menu built by entries each time the platform opens it, for a menu that depends on what’s selected or under the pointer at that moment: a table row’s menu acting on the selection. What it reads is read then, not followed.
Source§

fn a11y_label(self, label: impl IntoValue<String>) -> Self

Source§

fn a11y_description(self, description: impl IntoValue<String>) -> Self

Source§

fn a11y_role(self, role: Role) -> Self

Source§

fn a11y_hidden(self) -> Self

Source§

fn on_focus(self, handler: impl Fn() + 'static) -> Self

Called when this control gains keyboard focus.
Source§

fn on_blur(self, handler: impl Fn() + 'static) -> Self

Called when this control loses keyboard focus.
Source§

fn tab_index(self, index: u32) -> Self

Moves this control ahead in the Tab order. Controls with a tab index come first (lowest first); the rest follow in reading order. Prefer arranging the tree in the order users should visit it.
Source§

fn node_ref(self, node: NodeRef) -> Self

Points node at this widget’s node, for use_size and to focus it from code (NodeRef::focus).
Source§

fn test_id(self, id: impl Into<String>) -> Self

Last-resort handle for tests; prefer finding nodes by role and name.
Source§

impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> View for Table<T, K>

Source§

fn build(self, ui: &Ui) -> NodeId

Auto Trait Implementations§

§

impl<T = (), K = ()> !RefUnwindSafe for Table<T, K>

§

impl<T = (), K = ()> !Send for Table<T, K>

§

impl<T = (), K = ()> !Sync for Table<T, K>

§

impl<T = (), K = ()> !UnwindSafe for Table<T, K>

§

impl<T, K> Forget for Table<T, K>

§

impl<T, K> Freeze for Table<T, K>
where Value<Vec<T>>: Freeze, Rc<dyn Fn(&T) -> K>: Freeze, Vec<TableColumn<T>>: Freeze, Option<Signal<Vec<K>>>: Freeze, Option<Rc<dyn Fn(K)>>: Freeze, Option<ListHandle<K>>: Freeze, Option<Rc<dyn Fn(&T) -> Option<PathBuf>>>: Freeze,

§

impl<T, K> Unpin for Table<T, K>
where Value<Vec<T>>: Unpin, Rc<dyn Fn(&T) -> K>: Unpin, Vec<TableColumn<T>>: Unpin, Option<Signal<Vec<K>>>: Unpin, Option<Rc<dyn Fn(K)>>: Unpin, Option<ListHandle<K>>: Unpin, Option<Rc<dyn Fn(&T) -> Option<PathBuf>>>: Unpin,

§

impl<T, K> UnsafeUnpin for Table<T, K>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<V> Children for V
where V: View,

Source§

fn into_views(self, out: &mut Vec<AnyView>)

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.