Skip to main content

Column

Struct Column 

Source
pub struct Column<S, T> { /* private fields */ }
Expand description

One column of a DataTable or a ServerTable whose rows are T.

A column shows a field of the row with Column::text or Column::number, or any element with Column::custom. The table sorts by a column it receives through its sortable_column, which takes the key the way that table sorts.

use hypersig::Signals;
use hypersig_ui::Column;
use serde::{Deserialize, Serialize};

#[derive(Signals, Serialize, Deserialize)]
struct User {
    id: i32,
    email: String,
}

#[derive(Signals, Serialize, Deserialize)]
struct Users {
    users: Vec<User>,
}

let email: Column<Users, User> = Column::text("Email", User::email());

Implementations§

Source§

impl<S: 'static, T: 'static> Column<S, T>

Source

pub fn text(header: impl Into<String>, field: Sig<T, String>) -> Self

A column headed header that shows the text field field of each row.

Source

pub fn number<U: Number + Textual + 'static>( header: impl Into<String>, field: Sig<T, U>, ) -> Self

A column headed header that shows the number field field, aligned to the end.

Source

pub fn formatted<U: Number + 'static>( header: impl Into<String>, field: Sig<T, U>, format: NumberFormat, ) -> Self

A column headed header that shows the number field field written in format.

use hypersig::{NumberFormat, Signals};
use hypersig_ui::Column;
use serde::{Deserialize, Serialize};

#[derive(Signals, Serialize, Deserialize)]
struct Payment {
    amount: f64,
}

#[derive(Signals, Serialize, Deserialize)]
struct Ledger {
    payments: Vec<Payment>,
}

const DOLLARS: NumberFormat = NumberFormat::new().digits(2).prefix("$");
let amount: Column<Ledger, Payment> = Column::formatted("Amount", Payment::amount(), DOLLARS);
Source

pub fn custom( header: impl Into<String>, render: impl Fn(Item<S, T>) -> El<S> + 'static, ) -> Self

A column headed header whose cells hold what render returns for each row.

Source

pub fn visible(self, when: impl IntoExpr<S, bool>) -> Self

Shows the column only while when is true.

Trait Implementations§

Source§

impl<S, T> Debug for Column<S, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, T> !RefUnwindSafe for Column<S, T>

§

impl<S, T> !Send for Column<S, T>

§

impl<S, T> !Sync for Column<S, T>

§

impl<S, T> !UnwindSafe for Column<S, T>

§

impl<S, T> Freeze for Column<S, T>

§

impl<S, T> Unpin for Column<S, T>

§

impl<S, T> UnsafeUnpin for Column<S, T>

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.