pub struct TableBody { /* private fields */ }
Available on crate feature
yew
only.Expand description
A table body component that handles rendering of table rows, empty state, and loading state.
This component is part of the table_rs
Yew integration and is responsible for rendering
the <tbody>
section of a table, based on the provided data and configuration.
§Arguments
props
- The properties passed to the component.columns
- A list of column definitions (Vec<Column>
) specifying which fields to render.rows
- A vector of row data (Vec<HashMap<&'static str, String>>
) to display.loading
- A boolean flag indicating whether the table is in a loading state.classes
- ATableClasses
object defining CSS class names for customization.texts
- ATableTexts
object defining UI text like loading or empty messages.
§Returns
(Html): A rendered <tbody>
element, containing:
- A loading row if
loading
istrue
. - An empty state row if
rows
is empty. - The list of rows otherwise.
§Examples
use table_rs::yew::body::TableBody;
use table_rs::yew::types::{TableBodyProps, Column, TableClasses, TableTexts};
use yew::prelude::*;
use maplit::hashmap;
#[function_component(App)]
pub fn app() -> Html {
let rows = vec![
hashmap! { "name" => "Ferris".to_string(), "email" => "ferris@opensass.org".to_string() },
hashmap! { "name" => "Crab".to_string(), "email" => "crab@opensass.org".to_string() },
];
let columns = vec![
Column { id: "name", header: "Name", ..Default::default() },
Column { id: "email", header: "Email", ..Default::default() },
];
let props = TableBodyProps {
columns,
rows,
loading: false,
classes: Default::default(),
texts: Default::default(),
};
html! {
<TableBody ..props />
}
}
§See Also
Trait Implementations§
Source§impl BaseComponent for TableBodywhere
Self: 'static,
impl BaseComponent for TableBodywhere
Self: 'static,
Source§type Properties = TableBodyProps
type Properties = TableBodyProps
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 FunctionProvider for TableBody
impl FunctionProvider for TableBody
Source§type Properties = TableBodyProps
type Properties = TableBodyProps
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 TableBody
impl !RefUnwindSafe for TableBody
impl !Send for TableBody
impl !Sync for TableBody
impl Unpin for TableBody
impl !UnwindSafe for TableBody
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.