pub struct ColumnContext { /* private fields */ }Expand description
Context for a specific column, providing access to sorting and visibility controls.
This type is passed to TableColumn::render_header
and TableColumn::render_cell,
allowing columns to interact with table state.
§Sorting
request_sort: Request a sort operationsort_info: Get current sort state
§Column Visibility and Ordering
hide/show: Toggle visibilitymove_to,move_forward,move_backward: Reorderis_visible,position: Query state
§Example
impl TableColumn<User> for Col {
fn column_name(&self) -> String {
"col".into()
}
fn render_header(&self, context: ColumnContext, attributes: Vec<Attribute>) -> Element {
rsx! {
th { ..attributes,
button {
onclick: move |_| {
// Request ascending sort
context.request_sort(SortGesture::AddLast(Sort {
direction: SortDirection::Ascending,
}));
},
"Sort"
}
// Show sort indicator
if let Some(info) = context.sort_info() {
match info.direction {
SortDirection::Ascending => " ↑",
SortDirection::Descending => " ↓",
}
}
}
}
}
fn render_cell(&self, _context: ColumnContext, _row: &User, _attributes: Vec<Attribute>) -> Element {
rsx! { td {} }
}
}Implementations§
Source§impl ColumnContext
impl ColumnContext
Sourcepub fn request_sort(&self, sort: SortGesture)
pub fn request_sort(&self, sort: SortGesture)
Requests a sort operation on this column.
Use SortGesture::AddFirst to make this the primary sort,
AddLast to add as secondary, Toggle to flip direction, or Cancel to remove.
Sourcepub fn sort_info(&self) -> Option<SortInfo>
pub fn sort_info(&self) -> Option<SortInfo>
Returns the sort information for this column, or None if not sorted.
Use SortInfo.priority to show sort order (0 = primary) and SortInfo.direction for the arrow.
Sourcepub fn swap_with(&self, other_col: usize)
pub fn swap_with(&self, other_col: usize)
Swaps this column with another column in the display order.
Sourcepub fn show(&self, at_index: Option<usize>)
pub fn show(&self, at_index: Option<usize>)
Shows this column in the display. If at_index is None, appends to the end.
Sourcepub fn move_to(&self, new_index: usize)
pub fn move_to(&self, new_index: usize)
Moves this column to a specific display position (0-indexed).
Sourcepub fn move_forward(&self)
pub fn move_forward(&self)
Moves this column one position forward (towards index 0).
Sourcepub fn move_backward(&self)
pub fn move_backward(&self)
Moves this column one position backward (towards the end).
Sourcepub fn is_visible(&self) -> bool
pub fn is_visible(&self) -> bool
Returns whether this column is currently visible.
Sourcepub fn position(&self) -> Option<usize>
pub fn position(&self) -> Option<usize>
Returns the display position (0-indexed), or None if hidden.
Sourcepub fn reset_order(&self)
pub fn reset_order(&self)
Resets all columns to default visibility and order.
Trait Implementations§
Source§impl Clone for ColumnContext
impl Clone for ColumnContext
Source§fn clone(&self) -> ColumnContext
fn clone(&self) -> ColumnContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more