Struct TableView

Source
pub struct TableView<T, A = ()> { /* private fields */ }
Expand description

Scrollable table with typed row activation and controlled visual selection.

T is cloned when a row is activated; A is the application action returned by non-context callbacks. Self::bind_selected installs writable selection, while Self::selected is read-only. Activating an enabled row writes and/or invokes configured handlers even when its ID already equals the selection. Overflowing body axes paint overlay scrollbars above the clipped rows while the header remains fixed. Thumb dragging and centered track clicks do not activate rows; a disabled table accepts neither interaction.

§Examples

use ailloli_ui_widgets::controls::{TableCell, TableColumn, TableRow, TableView};
let table: TableView<i32> = TableView::new()
    .column(TableColumn::new("Value"))
    .row(TableRow::new(1).cell(TableCell::text("One")));
let _ = table;

Implementations§

Source§

impl<T: Clone + PartialEq + 'static, A: 'static> TableView<T, A>

Source

pub fn new() -> Self

Creates an enabled empty table with zebra stripes enabled.

It has no columns, rows, selection, handler, or body-height cap.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new();
let _ = table;
Source

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

Appends a column in display order.

§Examples
use ailloli_ui_widgets::controls::{TableColumn, TableView};
let table: TableView<i32> = TableView::new().column(TableColumn::new("Name"));
let _ = table;
Source

pub fn row(self, row: TableRow<T>) -> Self

Appends one row in display order.

§Examples
use ailloli_ui_widgets::controls::{TableRow, TableView};
let table: TableView<i32> = TableView::new().row(TableRow::new(1));
let _ = table;
Source

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

Extends rows in iterator order without clearing existing rows.

§Examples
use ailloli_ui_widgets::controls::{TableRow, TableView};
let table: TableView<i32> = TableView::new().rows([TableRow::new(1), TableRow::new(2)]);
let _ = table;
Source

pub fn selected(self, selected: impl Into<Binding<T>>) -> Self

Sets a read-only static or reactive selection and clears writable binding.

Every row with an equal ID paints selected. Row activation can still invoke on_select, but cannot mutate this binding.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().selected(1);
let _ = table;
Source

pub fn bind_selected(self, selected: impl Into<Signal<T>>) -> Self

Binds a writable table-level selection signal.

Activating an enabled row writes its ID even if equal to the current value, before invoking the optional callback.

§Examples
use ailloli_ui_runtime::component::State;
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().bind_selected(State::new(1));
let _ = table;
Source

pub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self

Sets static or reactive whole-table disabled state.

Disabled tables are not focusable and ignore input; all rows paint with disabled text/icon/progress treatment.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().disabled(true);
let _ = table;
Source

pub fn disabled_signal(self, disabled: Memo<bool>) -> Self

Uses a memo as the reactive whole-table disabled binding.

§Examples
use ailloli_ui_runtime::component::Memo;
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().disabled_signal(Memo::new(|| false));
let _ = table;
Source

pub fn on_select(self, f: impl Fn(T) -> A + 'static) -> Self

Dispatches the application action returned for an activated enabled row.

The handler runs even when the row ID already equals controlled selection. Disabled or out-of-range rows emit nothing.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32, i32> = TableView::new().on_select(|id| id);
let _ = table;
Source

pub fn on_select_ctx(self, f: impl Fn(&mut EventCtx<A>, T) + 'static) -> Self

Handles an activated enabled row with direct event-context access.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().on_select_ctx(|_ctx, _id| {});
let _ = table;
Source

pub fn table_style(self, style: TableViewStyle) -> Self

Replaces table style without altering explicit layout values.

§Examples
use ailloli_ui_widgets::controls::{TableView, TableViewStyle};
let table: TableView<i32> = TableView::new().table_style(TableViewStyle::default());
let _ = table;
Source

pub fn table_size(self, size: TableViewSize) -> Self

Re-derives style from the default theme and requested density.

This overwrites every prior table-style customization.

§Examples
use ailloli_ui_widgets::controls::{TableView, TableViewSize};
let table: TableView<i32> = TableView::new().table_size(TableViewSize::Compact);
let _ = table;
Source

pub fn max_body_height(self, height: f32) -> Self

Sets an optional maximum intrinsic body height in logical pixels.

Finite negatives become 0.0; finite nonnegative values are retained; NaN and either infinity clear the cap. Explicit layout height can still override intrinsic sizing.

§Examples
use ailloli_ui_widgets::controls::TableView;
let capped: TableView<i32> = TableView::new().max_body_height(144.0);
let uncapped: TableView<i32> = TableView::new().max_body_height(f32::NAN);
let _ = (capped, uncapped);
Source

pub fn zebra(self, enabled: bool) -> Self

Enables or disables alternate background on odd unselected/inactive rows.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().zebra(false);
let _ = table;
Source

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

Replaces the preferred table width.

Numeric inputs are logical pixels; [Length::Auto] preserves intrinsic sizing and [Length::Fill] requests the parent-provided width.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().width(420.0);
let _ = table;
Source

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

Replaces the preferred table height.

Numeric inputs are logical pixels. An explicit height controls the whole table, including its fixed header, and can override intrinsic body sizing.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().height(280.0);
let _ = table;
Source

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

Replaces the minimum-width declaration.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().min_width(240.0);
let _ = table;
Source

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

Replaces the maximum-width declaration.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().max_width(960.0);
let _ = table;
Source

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

Replaces the minimum-height declaration.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().min_height(120.0);
let _ = table;
Source

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

Replaces the maximum-height declaration.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().max_height(640.0);
let _ = table;
Source

pub fn fill(self) -> Self

Requests parent-fill sizing on both axes.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().fill();
let _ = table;
Source

pub fn fill_width(self) -> Self

Requests parent-fill width while preserving the height declaration.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().height(240.0).fill_width();
let _ = table;
Source

pub fn fill_height(self) -> Self

Requests parent-fill height while preserving the width declaration.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().width(360.0).fill_height();
let _ = table;
Source

pub fn margin(self, value: f32) -> Self

Replaces every outer margin edge with value logical pixels.

The value is stored verbatim, including negative and non-finite input.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().margin(8.0);
let _ = table;
Source

pub fn padding(self, value: f32) -> Self

Replaces every inner padding edge with value logical pixels.

The value is stored verbatim, including negative and non-finite input.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().padding(12.0);
let _ = table;
Source

pub fn flex_grow(self) -> Self

Sets this table’s flex-grow weight to one.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().flex_grow();
let _ = table;
Source

pub fn flex_grow_by(self, value: f32) -> Self

Sets the dimensionless flex-grow weight, clamped to at least zero.

NaN and negative infinity become zero; positive infinity is retained.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().flex_grow_by(2.0);
let _ = table;
Source

pub fn flex_shrink(self, value: f32) -> Self

Sets the dimensionless flex-shrink weight, clamped to at least zero.

NaN and negative infinity become zero; positive infinity is retained.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().flex_shrink(1.0);
let _ = table;
Source

pub fn flex_basis(self, value: impl Into<Length>) -> Self

Replaces the preferred main-axis size used by a flex parent.

Numeric inputs are logical pixels.

§Examples
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().flex_basis(320.0);
let _ = table;
Source

pub fn align_self(self, value: AlignItems) -> Self

Overrides the flex parent’s cross-axis alignment for this table.

§Examples
use ailloli_ui_core::style::AlignItems;
use ailloli_ui_widgets::controls::TableView;
let table: TableView<i32> = TableView::new().align_self(AlignItems::Center);
let _ = table;

Trait Implementations§

Source§

impl<T: Clone + PartialEq + 'static, A: 'static> Default for TableView<T, A>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Clone + PartialEq + 'static, A: 'static> IntoView<A> for TableView<T, A>

Source§

fn into_view(self) -> View<A>

Builds the retained component and preserves layout/flex metadata.

Source§

impl<T: Clone + PartialEq + 'static, A: 'static> LayoutExt for TableView<T, A>

Source§

fn layout_mut(&mut self) -> &mut LayoutStyle

Returns the widget’s mutable declarative size/inset state. Read more

Auto Trait Implementations§

§

impl<T, A> Freeze for TableView<T, A>
where T: Freeze,

§

impl<T, A = ()> !RefUnwindSafe for TableView<T, A>

§

impl<T, A = ()> !Send for TableView<T, A>

§

impl<T, A = ()> !Sync for TableView<T, A>

§

impl<T, A> Unpin for TableView<T, A>
where T: Unpin,

§

impl<T, A = ()> !UnwindSafe for TableView<T, A>

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<T, A> FlexItemExt<A> for T
where T: IntoView<A>,

Source§

fn flex_grow(self) -> View<A>

Sets flex-grow weight to one. Read more
Source§

fn flex_grow_by(self, value: f32) -> View<A>

Sets the dimensionless flex-grow weight. Read more
Source§

fn flex_shrink(self, value: f32) -> View<A>

Sets the dimensionless flex-shrink weight. Read more
Source§

fn flex_basis(self, value: impl Into<Length>) -> View<A>

Sets the preferred main-axis flex basis. Read more
Source§

fn align_self(self, value: AlignItems) -> View<A>

Overrides the parent cross-axis alignment for this view. Read more
Source§

fn fill_width(self) -> View<A>

Marks width as parent-fill in the view size hint. Read more
Source§

fn fill_height(self) -> View<A>

Marks height as parent-fill in the view size hint. Read more
Source§

fn fill(self) -> View<A>

Marks both axes as parent-fill in the view size hint. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T, A> IntoViewKeyExt<A> for T
where T: IntoView<A>,

§

fn key(self, key: impl Into<String>) -> View<A>

Converts self, assigns the owned key, and returns the view. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,