跳到正文

Table

虚拟化表格集合,包含表头、行和单元格部件。

正在加载交互演示…

#导入

从 quickgui 导入 Table。

use quickgui::*;

#用法

TableState::new(rows, columns)
    .element("issues")

#结构

  • Table::root
  • Table::header
  • Table::row
  • Table::cell_part

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

TableState

查看源码
pub fn new(row_count: usize) -> Self
with_selection_modepub fn with_selection_mode(mut self, mode: TableSelectionMode) -> Self—

Allow Shift ranges, platform-modified toggles, and Select All.

pub fn with_selection_mode(mut self, mode: TableSelectionMode) -> Self
查看源码
with_layoutpub fn with_layout(mut self, layout: TableLayout) -> Self—

Configures with layout for this part.

pub fn with_layout(mut self, layout: TableLayout) -> Self
查看源码
layoutpub const fn layout(&self) -> TableLayout—

Configures layout for this part.

pub const fn layout(&self) -> TableLayout
查看源码
set_layoutpub fn set_layout(&mut self, layout: TableLayout) -> bool—

Configures set layout for this part.

pub fn set_layout(&mut self, layout: TableLayout) -> bool
查看源码
row_countpub const fn row_count(&self) -> usize—

Configures row count for this part.

pub const fn row_count(&self) -> usize
查看源码
set_row_countpub fn set_row_count(&mut self, row_count: usize) -> bool—

Configures set row count for this part.

pub fn set_row_count(&mut self, row_count: usize) -> bool
查看源码
selection_modepub const fn selection_mode(&self) -> TableSelectionMode—

Configures selection mode for this part.

pub const fn selection_mode(&self) -> TableSelectionMode
查看源码
set_selection_modepub fn set_selection_mode(&mut self, mode: TableSelectionMode) -> bool—

Configures set selection mode for this part.

pub fn set_selection_mode(&mut self, mode: TableSelectionMode) -> bool
查看源码
selectionpub const fn selection(&self) -> &TableSelection—

The retained row selection.

pub const fn selection(&self) -> &TableSelection
查看源码
selection_versionpub const fn selection_version(&self) -> u64—

A counter bumped once every time the retained selection actually changes. Comparing this across a frame is cheaper than cloning the selection, and it is what the table itself uses to decide whether to dispatch [`TableSelectionChanged`].

pub const fn selection_version(&self) -> u64
查看源码
set_selectionpub fn set_selection(&mut self, selection: TableSelection) -> bool—

Replace the retained row selection, dropping rows past the current row count.

pub fn set_selection(&mut self, selection: TableSelection) -> bool
查看源码
selection_anchorpub const fn selection_anchor(&self) -> Option<usize>—

The row a Shift range extends from.

pub const fn selection_anchor(&self) -> Option<usize>
查看源码
is_row_selectedpub fn is_row_selected(&self, row: usize) -> bool—

Configures is row selected for this part.

pub fn is_row_selected(&self, row: usize) -> bool
查看源码
select_rowpub fn select_row(&mut self, row: usize) -> bool—

Select exactly one row and anchor future Shift ranges there.

pub fn select_row(&mut self, row: usize) -> bool
查看源码
toggle_row_selectionpub fn toggle_row_selection(&mut self, row: usize) -> bool—

Add or remove one row from a multiple selection. A single-selection table selects the row instead of toggling it, so the platform-modified click of a single-selection list behaves like an ordinary click.

pub fn toggle_row_selection(&mut self, row: usize) -> bool
查看源码
select_row_rangepub fn select_row_range(&mut self, row: usize) -> bool—

Replace the selection with the range between the anchor and `row`.

pub fn select_row_range(&mut self, row: usize) -> bool
查看源码
select_all_rowspub fn select_all_rows(&mut self) -> bool—

Select every row. A single-selection table refuses.

pub fn select_all_rows(&mut self) -> bool
查看源码
clear_row_selectionpub fn clear_row_selection(&mut self) -> bool—

Configures clear row selection for this part.

pub fn clear_row_selection(&mut self) -> bool
查看源码
editing_cellpub const fn editing_cell(&self) -> Option<TableCellPosition>—

The open inline editor, if any.

pub const fn editing_cell(&self) -> Option<TableCellPosition>
查看源码
begin_editpub fn begin_edit(&mut self, position: TableCellPosition, column_count: usize) -> bool—

Open an inline editor over one cell and make it the active cell. The application owns the editor element and its draft value; QuickGUI retains only which cell is being edited, gives that cell its own key context, and reports Return and Escape.

pub fn begin_edit(&mut self, position: TableCellPosition, column_count: usize) -> bool
查看源码
end_editpub fn end_edit(&mut self) -> Option<TableCellPosition>—

Close the open editor. Returns the cell that was being edited.

pub fn end_edit(&mut self) -> Option<TableCellPosition>
查看源码
column_widthpub fn column_width(&self, column: ElementId) -> Option<f32>—

The retained width of a resizable column.

pub fn column_width(&self, column: ElementId) -> Option<f32>
查看源码
set_column_widthpub fn set_column_width(&mut self, column: ElementId, width: f32) -> bool—

Replace one resizable column's width, clamped to its declared minimum and the table's maximum. A column that is not resizable is ignored.

pub fn set_column_width(&mut self, column: ElementId, width: f32) -> bool
查看源码
resize_columnpub fn resize_column(&mut self, column: ElementId, delta: f32) -> bool—

Move one resizable column's trailing edge by a logical-pixel delta.

pub fn resize_column(&mut self, column: ElementId, delta: f32) -> bool
查看源码
column_orderpub fn column_order(&self) -> &[u16]—

The declared column indices in their current display order.

pub fn column_order(&self) -> &[u16]
查看源码
move_columnpub fn move_column(&mut self, column_index: usize, delta: isize) -> bool—

Move one declared column to a different position in the display order.

pub fn move_column(&mut self, column_index: usize, delta: isize) -> bool
查看源码
selected_cellpub const fn selected_cell(&self) -> Option<TableCellPosition>—

Configures selected cell for this part.

pub const fn selected_cell(&self) -> Option<TableCellPosition>
查看源码
selected_rowpub fn selected_row(&self) -> Option<usize>—

Configures selected row for this part.

pub fn selected_row(&self) -> Option<usize>
查看源码
sortpub const fn sort(&self) -> Option<TableSort>—

Configures sort for this part.

pub const fn sort(&self) -> Option<TableSort>
查看源码
set_sortpub fn set_sort(&mut self, sort: Option<TableSort>) -> bool—

Configures set sort for this part.

pub fn set_sort(&mut self, sort: Option<TableSort>) -> bool
查看源码
clear_selectionpub fn clear_selection(&mut self) -> bool—

Configures clear selection for this part.

pub fn clear_selection(&mut self) -> bool
查看源码
select_cellpub fn select_cell(&mut self, position: TableCellPosition, column_count: usize) -> bool—

Make one cell active and collapse the row selection onto its row. This is the unmodified click and arrow-key behavior of every desktop list. Use [`Self::set_selection`] or [`Self::toggle_row_selection`] to change selection without moving the active cell.

pub fn select_cell(&mut self, position: TableCellPosition, column_count: usize) -> bool
查看源码
visible_rowspub fn visible_rows(&self) -> std::ops::Range<usize>—

Configures visible rows for this part.

pub fn visible_rows(&self) -> std::ops::Range<usize>
查看源码
list_statepub fn list_state(&self) -> &ListState—

Configures list state for this part.

pub fn list_state(&self) -> &ListState
查看源码
focus_handlepub fn focus_handle(id: impl Into<ElementId>) -> FocusHandle—

Configures focus handle for this part.

pub fn focus_handle(id: impl Into<ElementId>) -> FocusHandle
查看源码
row_idpub fn row_id(id: impl Into<ElementId>, row: usize) -> ElementId—

Configures row id for this part.

pub fn row_id(id: impl Into<ElementId>, row: usize) -> ElementId
查看源码
cell_idpub fn cell_id(id: impl Into<ElementId>, position: TableCellPosition) -> ElementId—

Configures cell id for this part.

pub fn cell_id(id: impl Into<ElementId>, position: TableCellPosition) -> ElementId
查看源码
column_header_idpub fn column_header_id(id: impl Into<ElementId>, column: ElementId) -> ElementId—

Configures column header id for this part.

pub fn column_header_id(id: impl Into<ElementId>, column: ElementId) -> ElementId
查看源码
resize_handle_idpub fn resize_handle_id(id: impl Into<ElementId>, column: ElementId) -> ElementId—

The stable identity of one column's resize handle.

pub fn resize_handle_id(id: impl Into<ElementId>, column: ElementId) -> ElementId
查看源码

TableState::element

查看源码
pub fn element<V, H, E, RenderHeader, RenderCell, Activate>( &mut self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, columns: &[TableColumn], access: fn(&mut V) -> &mut TableState, render_header: RenderHeader, render_cell: RenderCell, activate: Activate, ) -> Element where V: 'static, H: IntoElement, E: IntoElement, RenderHeader: FnMut(TableHeaderState<'_>) -> H, RenderCell: FnMut(TableCellState<'_>) -> E, Activate: Fn(&mut V, TableCellPosition, &mut EventContext) + Clone + 'static,

Build a complete unstyled virtualized, sortable, keyboard-navigable table. `render_header` owns every visible header declaration, including label, sort indicator, and the placement of the resize handle QuickGUI hands it. `render_cell` owns every visible cell declaration, including the inline editor it mounts while `editing` is set, and runs only for mounted rows. QuickGUI decorates those elements with fixed grid geometry, identities, pointer/keyboard behavior, and accessibility semantics but adds no paint. `activate` receives the current logical cell when Return is dispatched outside an editor; selection, sort, width, order, and editing state remain directly readable from `access`.

TableState::element_with

查看源码
pub fn element_with<V, H, E, RenderHeader, RenderCell, Activate>( &mut self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, columns: &[TableColumn], access_source: StateAccessor<V, TableState>, render_header: RenderHeader, render_cell: RenderCell, activate: Activate, ) -> Element where V: 'static, H: IntoElement, E: IntoElement, RenderHeader: FnMut(TableHeaderState<'_>) -> H, RenderCell: FnMut(TableCellState<'_>) -> E, Activate: Fn(&mut V, TableCellPosition, &mut EventContext) + Clone + 'static,

Build the table against a per-instance retained-state accessor. A host that renders many declared tables through one view passes an accessor that captures which [`TableState`] each registered listener resolves. Every row is a plain container; [`Self::element_with_rows`] lets the caller paint the rows too.

TableState::element_with_rows

查看源码
pub fn element_with_rows<V, R, H, E, RenderRow, RenderHeader, RenderCell, Activate>( &mut self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, columns: &[TableColumn], access_source: StateAccessor<V, TableState>, mut render_row: RenderRow, mut render_header: RenderHeader, mut render_cell: RenderCell, activate: Activate, ) -> Element where V: 'static, R: IntoElement, H: IntoElement, E: IntoElement, RenderRow: FnMut(TableRowState) -> R, RenderHeader: FnMut(TableHeaderState<'_>) -> H, RenderCell: FnMut(TableCellState<'_>) -> E, Activate: Fn(&mut V, TableCellPosition, &mut EventContext) + Clone + 'static,

Build the table with a caller-owned container for every mounted row. `render_row` returns the element a row's cells are laid out in. QuickGUI adds the grid tracks, the row height, the row identity, and the collection semantics on top of it, so the caller declares only the row's paint — a background, a divider, a hover state, or a [`selected_style`](Element::selected_style) that paints while the row is selected — never its layout. The renderer runs only for mounted rows.