Skip to main content

Table

Struct Table 

Source
pub struct Table { /* private fields */ }
Expand description

A data table widget with column headers, row selection, and keyboard navigation.

Implementations§

Source§

impl Table

Source

pub fn new() -> Self

Creates an empty table.

Source

pub fn columns(self, columns: Vec<TableColumn>) -> Self

Sets the column definitions.

Source

pub fn rows(self, rows: Vec<TableRow>) -> Self

Sets the row data.

Source

pub fn rows_simple(self, rows: Vec<Vec<impl Into<TableCell>>>) -> Self

Convenience: construct rows from Vec<Vec<impl Into>>.

Source

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

Sets a footer row displayed below all data rows.

Source

pub fn style(self, style: Style) -> Self

Sets the default cell style.

Source

pub fn header_style(self, style: Style) -> Self

Sets the header row style.

Source

pub fn select_style(self, style: Style) -> Self

Sets the selected row style.

Source

pub fn selected(&self) -> usize

Returns the currently selected row index.

Source

pub fn set_selected(&mut self, index: usize, cx: &mut EventCx<'_>)

Sets the selected row programmatically.

Source

pub fn row_count(&self) -> usize

Returns the number of rows.

Source

pub fn sort_by_column(&mut self, col: usize, cx: &mut EventCx<'_>)

Sorts rows by the given column index, in ascending order. Invalid column index is a no-op.

Source

pub fn set_column_width(&mut self, col: usize, width: u16, cx: &mut EventCx<'_>)

Sets the width of a specific column. Minimum width is 3.

Source

pub fn adjust_column_width( &mut self, col: usize, delta: i16, cx: &mut EventCx<'_>, )

Adjusts the width of a column by delta (positive = wider).

Trait Implementations§

Source§

impl Component for Table

Source§

fn render(&self, cx: &mut RenderCx<'_>)

渲染组件内容
Source§

fn measure(&self, _constraint: Constraint, _cx: &mut MeasureCx) -> Size

测量组件在给定约束下的自适应尺寸 Read more
Source§

fn event(&mut self, event: &Event, cx: &mut EventCx<'_>)

处理事件(可选实现)
Source§

fn layout(&mut self, rect: Rect, _cx: &mut LayoutCx<'_>)

布局回调——组件在此计算子节点 rect 并调用 child.layout() Read more
Source§

fn focusable(&self) -> bool

是否可聚焦(Tab 导航会跳过不可聚焦的组件)
Source§

fn style(&self) -> Style

返回组件样式(可选实现)
Source§

fn mount(&mut self, _cx: &mut EventCx<'_>)

首次挂载(初始化后调用)
Source§

fn unmount(&mut self, _cx: &mut EventCx<'_>)

从树卸载(退出前调用)
Source§

fn update(&mut self, _cx: &mut EventCx<'_>)

每次事件分发前调用
Source§

fn type_name(&self) -> &str

组件类型名(用于样式表类型选择器匹配)
Source§

fn id(&self) -> Option<&str>

组件 ID(用于样式表 #id 选择器匹配)
Source§

fn class(&self) -> Option<&str>

组件 class(用于样式表 .class 选择器匹配)
Source§

fn for_each_child(&self, _f: &mut dyn FnMut(&Node))

遍历子节点(为焦点系统等提供统一的树遍历接口)
Source§

fn for_each_child_mut(&mut self, _f: &mut dyn FnMut(&mut Node))

遍历子节点(可变版本)

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

§

impl UnwindSafe for Table

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