pub struct TableHeader { /* private fields */ }
Available on crate feature
yew
only.Expand description
A table header component that renders column headers with optional sorting functionality.
This component is part of the table_rs
Yew integration and is responsible for rendering
the <thead>
section of a table. It supports sortable columns and emits sort events when
a sortable header is clicked.
§Arguments
props
- The properties passed to the component.columns
- A list of column definitions (Vec<Column>
) specifying the headers to render.sort_column
- AnOption<&'static str>
indicating the currently sorted column, if any.sort_order
- ASortOrder
indicating whether the sort is ascending or descending.on_sort_column
- ACallback<&'static str>
triggered when a sortable column is clicked.classes
- ATableClasses
object defining CSS class names for customization.
§Returns
(Html): A rendered <thead>
element containing the table header row and interactive sorting logic.
§Examples
use table_rs::yew::header::TableHeader;
use table_rs::yew::types::{TableHeaderProps, Column, SortOrder, TableClasses};
use yew::prelude::*;
#[function_component(App)]
pub fn app() -> Html {
let columns = vec![
Column { id: "name", header: "Name", sortable: true, ..Default::default() },
Column { id: "email", header: "Email", sortable: false, ..Default::default() },
];
let sort_order = use_state(|| SortOrder::Asc);
let sort_column = use_state(|| Some("name"));
let props = TableHeaderProps {
columns,
sort_column: sort_column,
sort_order: sort_order,
on_sort_column: Callback::from(|col_id| web_sys::console::log_1(&format!("Sort: {}", col_id).into())),
classes: Default::default(),
};
html! {
<TableHeader ..props />
}
};
§See Also
Trait Implementations§
Source§impl BaseComponent for TableHeaderwhere
Self: 'static,
impl BaseComponent for TableHeaderwhere
Self: 'static,
Source§type Properties = TableHeaderProps
type Properties = TableHeaderProps
The Component’s Properties.
Source§fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool
fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool
Updates component’s internal state.
Source§fn changed(
&mut self,
_ctx: &Context<Self>,
_old_props: &Self::Properties,
) -> bool
fn changed( &mut self, _ctx: &Context<Self>, _old_props: &Self::Properties, ) -> bool
React to changes of component properties.
Source§fn view(&self, ctx: &Context<Self>) -> HtmlResult
fn view(&self, ctx: &Context<Self>) -> HtmlResult
Returns a component layout to be rendered.
Source§fn rendered(&mut self, _ctx: &Context<Self>, _first_render: bool)
fn rendered(&mut self, _ctx: &Context<Self>, _first_render: bool)
Notified after a layout is rendered.
Source§fn prepare_state(&self) -> Option<String>
fn prepare_state(&self) -> Option<String>
Prepares the server-side state.
Source§impl Debug for TableHeader
impl Debug for TableHeader
Source§impl FunctionProvider for TableHeader
impl FunctionProvider for TableHeader
Source§type Properties = TableHeaderProps
type Properties = TableHeaderProps
Properties for the Function Component.
Source§fn run(ctx: &mut HookContext, props: &Self::Properties) -> HtmlResult
fn run(ctx: &mut HookContext, props: &Self::Properties) -> HtmlResult
Auto Trait Implementations§
impl !Freeze for TableHeader
impl !RefUnwindSafe for TableHeader
impl !Send for TableHeader
impl !Sync for TableHeader
impl Unpin for TableHeader
impl !UnwindSafe for TableHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self
to a value of a Properties
struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self
to a value of a Properties
struct.Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.