Skip to content

DataGrid

Rows of an action with paging, sorting and filters.

Example

CodeNameKindPriceStock
P-001Field notes 101Book₺91.6937
P-002Garden trowel 102Tool₺170.8874
P-003Fern 103Plant₺250.0721
P-004City atlas 104Book₺329.2658
P-005Hand saw 105Tool₺408.455
P-006Olive tree 106Plant₺487.6442
Show code
use crate::data::{Kind, Product, search_products};
use zeyn::prelude::*;

pub fn overview(_ctx: &Ctx) -> Node {
    DataGrid::of(search_products)
        .paging(Paging::pages(6))
        .column(Product::code)
        .width(100)
        .column(Product::name)
        .flex(1)
        .filter()
        .column(Product::kind)
        .width(110)
        .badge(|k| match k {
            Kind::Book => Tone::Info,
            Kind::Tool => Tone::Neutral,
            Kind::Plant => Tone::Success,
        })
        .column(Product::price)
        .width(130)
        .column(Product::stock)
        .width(130)
        .progress(90)
        .into()
}