XU XUv0.13.1
中文

UI / WIDGETS / Data

Table

Browse structured records in columns

Run the Xu example

The example executes in the browser using the Xu/WASM runtime.

What to try

Click a column header to change sorting.

Usage notes

Column types determine sorting semantics. Sort numeric columns by value and balance column and minimum widths against available space.

Create through Screen

The Screen constructor returns a node ID. Pass that ID to Screen layout, state and event APIs. It is separate from the standalone control object documented below.

Native Xu setup fragment: call configure during initialization of an existing Screen. See the complete example for window creation, event dispatch and cleanup.

#ui/widgets

fn configure(screen $&widgets.Screen) int {
    options := ["Design","Develop","Review"]
    id := screen.table(&options,3,0) or >>
    screen.place(id,24.0,24.0,320.0,80.0) or >>
    << id
}

($&Screen) table

XuAPI
pub fn (s $&Screen) table(headers &[]string,rows int,selected int) int

Purpose

Create Table in Screen and return the component node ID; throw on creation failure.

Parameters

s $&Screen
The Screen instance used by this call (exclusive borrow).
headers &[]string
headers (read-only borrow; caller keeps the original; type &[]string)
rows int
rows (int)
selected int
selected (int)

Returns

int — component node ID for place and other Screen methods.

Placement, state and events

The application owns the component. Screen.place positions nodes; Screen.set_enabled and Screen.set_visible control availability and visibility. Present again after state changes, handle or errors, and keep topology changes outside paint callbacks. ToastHost uses its own queue API.

Action · Styles · UI lifecycle and styling guide

Screen.place · Screen.set_enabled · Screen.set_visible

Standalone control object API

These types and methods support applications that manage control objects, input and painting directly. Their receiver is a control object, not a Screen node ID. For Screen usage, use the constructor above and the Screen methods in the Widgets module.

($&Table) set_locale

XuAPI
pub fn (table $&Table) set_locale(locale &Locale) int

Purpose

Operation on $&Table: set locale. Throws on failure; handle the error or propagate it to the caller.

Parameters

table $&Table
The Table instance used by this call (exclusive borrow).
locale &Locale
locale (read-only borrow; caller keeps the original; type &Locale)

Returns

int — a value of this type

struct Table

XuAPI
pub struct Table {

}

Purpose

A bounded single-line, equal-width column table: 1..16 columns and at most 768 cells (512 rows). Header activation sorts locally unless manual mode is set. Only visible rows are shaped, and their cache slots are reused on scroll.

Public fields

This type has no public fields.

(&Table) id

XuAPI
pub fn (t &Table) id() int

Purpose

Return the unique integer ID of the element or control.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

int — a value of this type

(&Table) bounds

XuAPI
pub fn (t &Table) bounds() layout.Rect

Purpose

Return the bounding Rectangle of the control or geometry.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

layout.Rect — a value of this type

(&Table) count

XuAPI
pub fn (t &Table) count() int

Purpose

Return the number of items in this control.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

int — a value of this type

(&Table) column_count

XuAPI
pub fn (t &Table) column_count() int

Purpose

Operation on &Table: column count.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

int — a value of this type

(&Table) selected

XuAPI
pub fn (t &Table) selected() int

Purpose

Get or test the currently selected index, node, or state.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

int — a value of this type

(&Table) sort_column

XuAPI
pub fn (t &Table) sort_column() int

Purpose

Operation on &Table: sort column.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

int — a value of this type

(&Table) sort_descending

XuAPI
pub fn (t &Table) sort_descending() bool

Purpose

Operation on &Table: sort descending.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

bool — true or false

(&Table) scroll_offset

XuAPI
pub fn (t &Table) scroll_offset() f64

Purpose

Operation on &Table: scroll offset.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

f64 — a value of this type

(&Table) needs_paint

XuAPI
pub fn (t &Table) needs_paint() bool

Purpose

Return whether the control needs repainting; call painted after painting to clear the flag.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

bool — true or false

($&Table) painted

XuAPI
pub fn (t $&Table) painted()

Purpose

Acknowledge the painted frame and clear the dirty flag; this is not a query.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).

Returns

This call does not return a value.

(&Table) is_selectable

XuAPI
pub fn (t &Table) is_selectable() bool

Purpose

Operation on &Table: whether it is selectable.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

bool — true or false

($&Table) set_selectable

XuAPI
pub fn (t $&Table) set_selectable(selectable bool)

Purpose

Operation on $&Table: set selectable.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
selectable bool
selectable (bool)

Returns

This call does not return a value.

(&Table) has_popup_open

XuAPI
pub fn (t &Table) has_popup_open() bool

Purpose

Operation on &Table: whether it has popup open.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

bool — true or false

(&Table) popup_bounds

XuAPI
pub fn (t &Table) popup_bounds() layout.Rect

Purpose

Operation on &Table: popup bounds.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

layout.Rect — a value of this type

($&Table) set_viewport

XuAPI
pub fn (t $&Table) set_viewport(viewport &layout.Rect)

Purpose

Operation on $&Table: set viewport.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
viewport &layout.Rect
viewport (read-only borrow; caller keeps the original; type &layout.Rect)

Returns

This call does not return a value.

($&Table) paint_popup_styled

XuAPI
pub fn (t $&Table) paint_popup_styled(frame $&draw.Frame,styles &Styles) int

Purpose

Operation on $&Table: paint popup styled. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
frame $&draw.Frame
frame (exclusive borrow; may modify the original; type $&draw.Frame)
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

(&Table) cursor

XuAPI
pub fn (t &Table) cursor() int

Purpose

Execute cursor on &Table.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

int — a value of this type

(&Table) is_enabled

XuAPI
pub fn (t &Table) is_enabled() bool

Purpose

Return whether the control is currently enabled.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

bool — true or false

(&Table) is_focused

XuAPI
pub fn (t &Table) is_focused() bool

Purpose

Return whether the control currently has input focus.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

bool — true or false

(&Table) is_read_only

XuAPI
pub fn (t &Table) is_read_only() bool

Purpose

Operation on &Table: whether it is read only.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

bool — true or false

($&Table) cancel

XuAPI
pub fn (t $&Table) cancel()

Purpose

Execute cancel on $&Table.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&Table) set_focus

XuAPI
pub fn (t $&Table) set_focus(focused bool)

Purpose

Operation on $&Table: set focus.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
focused bool
focused (bool)

Returns

This call does not return a value.

($&Table) set_enabled

XuAPI
pub fn (t $&Table) set_enabled(enabled bool)

Purpose

Operation on $&Table: set enabled.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
enabled bool
enabled (bool)

Returns

This call does not return a value.

($&Table) set_read_only

XuAPI
pub fn (t $&Table) set_read_only(value bool) int

Purpose

Operation on $&Table: set read only. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
value bool
value (bool)

Returns

int — a value of this type

($&Table) set_cell

XuAPI
pub fn (t $&Table) set_cell(row int,column int,text &string) int

Purpose

Operation on $&Table: set cell. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
row int
row (int)
column int
column (int)
text &string
text (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

(&Table) cell

XuAPI
pub fn (t &Table) cell(row int,column int) string

Purpose

Execute cell on &Table. Throws on failure; handle the error or propagate it to the caller.

Parameters

t &Table
The Table instance used by this call (borrow).
row int
row (int)
column int
column (int)

Returns

string — result string

($&Table) set_rows

XuAPI
pub fn (t $&Table) set_rows(count int) int

Purpose

Operation on $&Table: set rows. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
count int
count (int)

Returns

int — a value of this type

($&Table) set_selected

XuAPI
pub fn (t $&Table) set_selected(index int) int

Purpose

Operation on $&Table: set selected. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
index int
index (int)

Returns

int — a value of this type

($&Table) set_scroll_offset

XuAPI
pub fn (t $&Table) set_scroll_offset(offset f64) int

Purpose

Operation on $&Table: set scroll offset. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
offset f64
offset (f64)

Returns

int — a value of this type

($&Table) set_bounds

XuAPI
pub fn (t $&Table) set_bounds(bounds &layout.Rect) int

Purpose

Operation on $&Table: set bounds. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
bounds &layout.Rect
bounds (read-only borrow; caller keeps the original; type &layout.Rect)

Returns

int — a value of this type

(&Table) style_or

XuAPI
pub fn (t &Table) style_or(styles &Styles) ControlStyle

Purpose

Operation on &Table: style or.

Parameters

t &Table
The Table instance used by this call (borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

ControlStyle — a value of this type

($&Table) set_style

XuAPI
pub fn (t $&Table) set_style(style &ControlStyle) int

Purpose

Operation on $&Table: set style. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
style &ControlStyle
style (read-only borrow; caller keeps the original; type &ControlStyle)

Returns

int — a value of this type

($&Table) clear_style

XuAPI
pub fn (t $&Table) clear_style()

Purpose

Operation on $&Table: clear style.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).

Returns

This call does not return a value.

($&Table) apply_styles

XuAPI
pub fn (t $&Table) apply_styles(styles &Styles) int

Purpose

Resolve and apply theme metrics to the control. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

(&Table) row_bounds

XuAPI
pub fn (t &Table) row_bounds(row int) layout.Rect

Purpose

Operation on &Table: row bounds.

Parameters

t &Table
The Table instance used by this call (borrow).
row int
row (int)

Returns

layout.Rect — a value of this type

(&Table) header_bounds

XuAPI
pub fn (t &Table) header_bounds(column int) layout.Rect

Purpose

Operation on &Table: header bounds.

Parameters

t &Table
The Table instance used by this call (borrow).
column int
column (int)

Returns

layout.Rect — a value of this type

(&Table) row_text

XuAPI
pub fn (t &Table) row_text(source_row int) string

Purpose

Operation on &Table: row text.

Parameters

t &Table
The Table instance used by this call (borrow).
source_row int
source_row (int)

Returns

string — result string

($&Table) input

XuAPI
pub fn (t $&Table) input(input &ui.InputEvent) Action

Purpose

Process routed mouse, keyboard, or touch input events. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
input &ui.InputEvent
input (read-only borrow; caller keeps the original; type &ui.InputEvent)

Returns

Action — input result with kind, id, repaint and focus requests.

($&Table) route

XuAPI
pub fn (t $&Table) route(kind int,input &ui.InputEvent) Action

Purpose

Route and dispatch the input event to matching targets. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
kind int
kind tag (int)
input &ui.InputEvent
input (read-only borrow; caller keeps the original; type &ui.InputEvent)

Returns

Action — input result with kind, id, repaint and focus requests.

($&Table) event

XuAPI
pub fn (t $&Table) event(event &ui.Event) Action

Purpose

Handle and respond to window or system lifecycle and interaction events. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
event &ui.Event
event (read-only borrow; caller keeps the original; type &ui.Event)

Returns

Action — input result with kind, id, repaint and focus requests.

($&Table) measure_styled

XuAPI
pub fn (t $&Table) measure_styled(styles &Styles) layout.Size

Purpose

Operation on $&Table: measure styled. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

layout.Size — a value of this type

($&Table) dispose

XuAPI
pub fn (t $&Table) dispose()

Purpose

Release and dispose native resources and underlying handles.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).

Returns

This call does not return a value.

(&Table) selected_text

XuAPI
pub fn (t &Table) selected_text() string

Purpose

Operation on &Table: selected text.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

string — result string

(&Table) column_width

XuAPI
pub fn (t &Table) column_width(column int) f64

Purpose

Operation on &Table: column width. Throws on failure; handle the error or propagate it to the caller.

Parameters

t &Table
The Table instance used by this call (borrow).
column int
column (int)

Returns

f64 — a value of this type

($&Table) set_column_width

XuAPI
pub fn (t $&Table) set_column_width(column int,width f64) int

Purpose

Operation on $&Table: set column width. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
column int
column (int)
width f64
width (f64)

Returns

int — a value of this type

($&Table) set_column_alignment

XuAPI
pub fn (t $&Table) set_column_alignment(column int,alignment f64) int

Purpose

Operation on $&Table: set column alignment. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
column int
column (int)
alignment f64
alignment (f64)

Returns

int — a value of this type

($&Table) set_horizontal_offset

XuAPI
pub fn (t $&Table) set_horizontal_offset(offset f64) int

Purpose

Operation on $&Table: set horizontal offset. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
offset f64
offset (f64)

Returns

int — a value of this type

(&Table) horizontal_offset

XuAPI
pub fn (t &Table) horizontal_offset() f64

Purpose

Operation on &Table: horizontal offset.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

f64 — a value of this type

($&Table) set_status

XuAPI
pub fn (t $&Table) set_status(text &string) int

Purpose

Operation on $&Table: set status. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
text &string
text (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

($&Table) paint_styled

XuAPI
pub fn (t $&Table) paint_styled(frame $&draw.Frame,styles &Styles) int

Purpose

Operation on $&Table: paint styled. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
frame $&draw.Frame
frame (exclusive borrow; may modify the original; type $&draw.Frame)
styles &Styles
styles (read-only borrow; caller keeps the original; type &Styles)

Returns

int — a value of this type

($&Table) set_column_min_width

XuAPI
pub fn (t $&Table) set_column_min_width(column int,width f64) int

Purpose

Operation on $&Table: set column min width. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
column int
column (int)
width f64
width (f64)

Returns

int — a value of this type

(&Table) row_at

XuAPI
pub fn (t &Table) row_at(view_row int) int

Purpose

Source row indices remain stable while the view is sorted. cell/set_cell address source rows; view_cell and row_at address displayed rows. Throws on failure; handle the error or propagate it to the caller.

Parameters

t &Table
The Table instance used by this call (borrow).
view_row int
view_row (int)

Returns

int — a value of this type

(&Table) view_row

XuAPI
pub fn (t &Table) view_row(source_row int) int

Purpose

Operation on &Table: view row. Throws on failure; handle the error or propagate it to the caller.

Parameters

t &Table
The Table instance used by this call (borrow).
source_row int
source_row (int)

Returns

int — a value of this type

(&Table) selected_row

XuAPI
pub fn (t &Table) selected_row() int

Purpose

Operation on &Table: selected row. Throws on failure; handle the error or propagate it to the caller.

Parameters

t &Table
The Table instance used by this call (borrow).

Returns

int — a value of this type

(&Table) view_cell

XuAPI
pub fn (t &Table) view_cell(row int,column int) string

Purpose

Operation on &Table: view cell. Throws on failure; handle the error or propagate it to the caller.

Parameters

t &Table
The Table instance used by this call (borrow).
row int
row (int)
column int
column (int)

Returns

string — result string

($&Table) set_selected_row

XuAPI
pub fn (t $&Table) set_selected_row(source_row int) int

Purpose

Operation on $&Table: set selected row. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
source_row int
source_row (int)

Returns

int — a value of this type

($&Table) sort_by

XuAPI
pub fn (t $&Table) sort_by(column int,descending bool) int

Purpose

Operation on $&Table: sort by. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
column int
column (int)
descending bool
descending (bool)

Returns

int — a value of this type

($&Table) refresh_sort

XuAPI
pub fn (t $&Table) refresh_sort() int

Purpose

Operation on $&Table: refresh sort. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).

Returns

int — a value of this type

($&Table) set_sort_kind

XuAPI
pub fn (t $&Table) set_sort_kind(column int,kind int) int

Purpose

Operation on $&Table: set sort kind. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
column int
column (int)
kind int
kind tag (int)

Returns

int — a value of this type

($&Table) set_local_sort

XuAPI
pub fn (t $&Table) set_local_sort(enabled bool) int

Purpose

Manual mode keeps header state/events and lets a remote data source own order. Throws on failure; handle the error or propagate it to the caller.

Parameters

t $&Table
The Table instance used by this call (exclusive borrow).
enabled bool
enabled (bool)

Returns

int — a value of this type

Complete native example

Component Workshop · Back to Widgets