= Yew Table

A simple table component for the Yew web framework.

NOTE: This crate is still at a very early stage; Enjoy It Responsibly™.

== Usage

.Use the Table component by setting the columns and data properties.

[source,rust]

impl Renderable for Model { fn view(&self) -> Html { // Define the columns. The first string is the field name, the second is the label. let columns = columns![ ("id", "Id.") ("description", "Description") ("duedate", "Due date") ("status", "Status") ("isfavorite", "Fav.") ("is_archived", "Arch.") ];

    html! {
        <>
            // Here, self.tasks is a Vec<Task>
            <Table<Task>: columns=columns, data=&self.tasks,/>
        </>
    }
}

}

.Implement the TableData trait for the struct to be used.

[source,rust]

[derive(Default, Clone, PartialEq, Serialize)]

pub struct Task { pub id: String, // ... }

impl TableData for Task { fn getfieldashtml(&self, fieldname: &str) -> Html> { match field_name { // Define how each field should be rendered. No restrictions. "id" => html! { { &self.id } }, // ... } }

}

== Example

An example Yew app showing a plain table can be found in the examples folder. Just run the contained run.sh script.

== License

link:LICENSE[MIT] © 2019 Alexis Luengas