Skip to main content

Table

Struct Table 

Source
pub struct Table { /* private fields */ }
Expand description

A data table. columns become the header; the children are the rows (tr![td![..], ..]), placed in the body. Wide tables scroll sideways inside their box instead of breaking the page.

let t = Table![columns = ["Name", "Score"], striped = true,
    tr![td!["Ada"], td!["98"]],
    tr![td!["Grace"], td!["95"]],
];
let html = render_static(t);
assert!(html.contains(r#"<table class="nr-table nr-table-striped">"#), "{html}");
assert!(html.contains(r#"<th scope="col">Name</th>"#) && html.contains("<tbody><tr><td>Ada</td>"));

Implementations§

Source§

impl Table

Source

pub fn new() -> Self

Source

pub fn class(self, v: impl Into<String>) -> Self

Extra classes for the outer element. They win over the defaults.

Source

pub fn unstyled(self, v: bool) -> Self

Leave out the default classes of the outer element.

Source

pub fn with(self, part: impl Part) -> Self

Add an attribute (class(..), id(..), aria(..), …) or a child.

Source

pub fn columns<I, S>(self, v: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Header cells, in order.

Source

pub fn caption(self, v: impl Into<String>) -> Self

A visible <caption> (also the table’s accessible name).

Source

pub fn striped(self, v: bool) -> Self

Source

pub fn compact(self, v: bool) -> Self

Source

pub fn bordered(self, v: bool) -> Self

Lines between cells.

Source

pub fn hoverable(self, v: bool) -> Self

Highlight the row under the pointer.

Source

pub fn sticky_header(self, v: bool) -> Self

The header stays visible while the body scrolls.

Source

pub fn radius(self, v: Radius) -> Self

Source

pub fn empty(self, v: impl View) -> Self

Shown across the table when there are no rows.

Trait Implementations§

Source§

impl Default for Table

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl View for Table

Auto Trait Implementations§

§

impl !RefUnwindSafe for Table

§

impl !Sync for Table

§

impl !UnwindSafe for Table

§

impl Forget for Table

§

impl Freeze for Table

§

impl Move for Table

§

impl Send for Table

§

impl Unpin for Table

§

impl UnsafeUnpin for Table

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<V, E> IntoViewResult<E> for V
where V: View,

Source§

impl<V> Part for V
where V: View,

Source§

fn apply(self, el: &mut Element)

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.