You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/lib.rs
+52-57Lines changed: 52 additions & 57 deletions
Original file line number
Diff line number
Diff line change
@@ -60,18 +60,18 @@
60
60
//! - **`head_cell_renderer`** - Specifies the name of the header cell renderer component. Used to customize the rendering of header cells. Defaults to [`DefaultTableHeaderRenderer`]. See the [custom_renderers_svg example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/custom_renderers_svg/src/main.rs) for more information.
61
61
//! - **`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>` to allow
62
62
//! for easy local data use. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
63
-
//! - **`row_type`** - Specifies the type of the rows in the table. Defaults to the struct that this is applied to.
63
+
//! - **`row_type`** - Specifies the type of the rows in the table. Defaults to the struct that this is applied to. See the [custom_type example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_type/src/main.rs) for more information.
64
64
//!
65
65
//! ## Field attributes
66
66
//!
67
67
//! These attributes can be applied to any field in the struct.
68
68
//!
69
-
//! - **`key`** - Specifies the field that is used as the key for each row. This is required on exactly one field.
70
69
//! - **`class`** - Specifies the classes that are applied to each cell (head and body) in the field's column. Can be used in conjuction with `classes_provider` to customize the classes.
71
70
//! - **`head_class`** - Specifies the classes that are applied to the header cell in the field's column. Can be used in conjuction with `classes_provider` to customize the classes.
72
71
//! - **`cell_class`** - Specifies the classes that are applied to the body cells in the field's column. Can be used in conjuction with `classes_provider` to customize the classes.
73
72
//! - **`skip`** - Specifies that the field should be skipped. This is useful for fields that are not displayed in the table.
74
73
//! - **`skip_sort`** - Only applies if `sortable` is set on the struct. Specifies that the field should not be used for sorting. Clicking it's header will not do anything.
74
+
//! - **`skip_header`** - Makes the title of the field not be displayed in the head row.
75
75
//! - **`title`** - Specifies the title that is displayed in the header cell. Defaults to the field name converted to title case (`this_field` becomes `"This Field"`).
76
76
//! - **`renderer`** - Specifies the name of the cell renderer component. Used to customize the rendering of cells.
77
77
//! Defaults to [`DefaultNumberTableCellRenderer`] for number types and [`DefaultTableCellRenderer`] for anything else.
@@ -97,13 +97,10 @@ Example:
97
97
```
98
98
# use leptos::*;
99
99
# use leptos_struct_table::*;
100
-
# use serde::{Deserialize, Serialize};
101
-
# use async_trait::async_trait;
102
100
# use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
//! For more detailed information please have a look at the `custom_renderers_svg` example for a complete customization.
254
+
//! For more detailed information please have a look at the [custom_renderers_svg example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_renderers_svg/src/main.rs) for a complete customization.
261
255
//!
262
256
//!
263
-
//! ### Editable Cells
257
+
//! ## Editable Cells
264
258
//!
265
259
//! You might have noticed the type parameter `F` in the custom cell renderer above. This can be used
266
260
//! to emit an event when the cell is changed. In the simplest case you can use a cell renderer that
//! // Then in the table component you can listen to the `on_change` event:
314
294
//!
315
295
//! #[component]
316
296
//! pub fn App() -> impl IntoView {
317
-
//! # let items = create_rw_signal(vec![Book::default(), Book::default()]);
318
-
//! let on_change = move |evt: ChangeEvent<Book, BookColumnName, BookColumnValue>| {
319
-
//! // Do something
297
+
//! let rows = vec![Book::default(), Book::default()];
298
+
//!
299
+
//! let on_change = move |evt: ChangeEvent<Book>| {
300
+
//! logging::log!("Changed row at index {}:\n{:#?}", evt.row_index, evt.changed_row);
320
301
//! };
321
302
//!
322
303
//! view! {
323
-
//! <BookTable items=items on_change=on_change />
304
+
//! <table>
305
+
//! <TableContent rows on_change />
306
+
//! </table>
324
307
//! }
325
308
//! }
326
309
//! ```
327
310
//!
328
-
//! Please have a look at the `editable` example for fully working example.
311
+
//! Please have a look at the [editable example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/editable/src/main.rs) for fully working example.
//! Please have a look at the [pagination example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/pagination/src/main.rs) for more information on how to use pagination.
0 commit comments