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
-**Async data loading** - The data is loaded asynchronously. This allows for loading data from a REST API or a database etc.
18
-
-**Selectable** - Optional. You can enable single or multi-select.
19
-
-**Fully Customizable** - You can customize every aspect of the table by plugging in your own components for rendering rows, cells, headers. See [Custom Renderers](#custom-renderers) for more information.
17
+
-**Easy to use** - yet powerful.
18
+
-**Async data loading** - The data is loaded asynchronously. This allows to load data from a REST API or a database etc.
19
+
-**Selection** - Can be turned off or single/multi select
20
+
-**Customization** - You can customize every aspect of the table by plugging in your own components for rendering rows, cells, headers. See [Custom Renderers](#custom-renderers) for more information.
20
21
-**Headless** - No default styling is applied to the table. You can fully customize the classes that are applied to the table. See [Classes customization](#classes-customization) for more information.
21
22
-**Sorting** - Optional. If turned on: Click on a column header to sort the table by that column. You can even sort by multiple columns.
22
23
-**Virtualization** - Only the visible rows are rendered. This allows for very large tables.
23
-
-**Editable** - Optional. You can provide custom renderers for editable cells. See [Editable Cells](#editable-cells) for more information.
24
+
-**Pagination** - Instead of virtualization you can paginate the table.
25
+
-**Caching** - Only visible rows are loaded and cached.
26
+
-**Editing** - Optional. You can provide custom renderers for editable cells. See [Editable Cells](#editable-cells) for more information.
@@ -64,32 +64,24 @@ The `#[table(...)]` attribute can be used to customize the generated component.
64
64
65
65
These attributes can be applied to the struct itself.
66
66
67
-
-**`sortable`** - Specifies that the table should be sortable. This makes the header clickable to toggle sorting.
68
-
-**`selection_mode`** - Specifies the selection mode. Can be one of `none`, `single`, (TODO: `multiple`). Defaults to `none`.
69
-
If given `single` then the generated component has a `selected_key: RwSignal<Option<K>>` property that can be used to get/set the selected key (of type K, the field specified by `#[table(key)]` - see below).
70
-
Clicking on a row will set the selected key to the key of that row.
71
-
-**`component_name`** - Specifies the name of the generated component. Defaults to `StructNameTable`.
72
-
-**`classes_provider`** - Specifies the name of the class provider. Used to customize the classes that are applied to the table.
73
-
For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`] for more information.
74
-
-**`tag`** - Specifies the tag that is used as the root element for the table. Defaults to `"table"`.
75
-
-**`row_renderer`** - Specifies the name of the row renderer component. Used to customize the rendering of rows. Defaults to [`DefaultTableRowRenderer`].
76
-
-**`head_row_renderer`** - Specifies the name of the head row renderer component/tag. Used to customize the rendering of the head rows. Defaults to the tag `tr`. This only takes a `class` attribute.
77
-
-**`head_cell_renderer`** - Specifies the name of the header cell renderer component. Used to customize the rendering of header cells. Defaults to [`DefaultTableHeaderRenderer`].
78
-
-**`thead_renderer`** - Specifies the name of the thead renderer component. Used to customize the rendering of the thead. Defaults to the tag `thead`. Takes no attributes.
79
-
-**`tbody_renderer`** - Specifies the name of the tbody renderer component. Used to customize the rendering of the tbody. Defaults to the tag `tbody`. Takes no attributes.
80
-
-**`row_class`** - Specifies the classes that are applied to each row. Can be used in conjuction with `classes_provider` to customize the classes.
81
-
-**`head_row_class`** - Specifies the classes that are applied to the header row. Can be used in conjuction with `classes_provider` to customize the classes.
67
+
-**`sortable`** - Specifies that the table should be sortable. This makes the header titles clickable to control sorting. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
68
+
-**`classes_provider`** - Specifies the name of the class provider. Used to quickly customize all of the classes that are applied to the table.
69
+
For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`] and [tailwind example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/tailwind/src/main.rs) for more information.
70
+
-**`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.
71
+
-**`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>` to allow
72
+
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.
73
+
-**`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.
82
74
83
75
### Field attributes
84
76
85
77
These attributes can be applied to any field in the struct.
86
78
87
-
-**`key`** - Specifies the field that is used as the key for each row. This is required on exactly one field.
88
79
-**`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.
89
80
-**`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.
90
81
-**`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.
91
82
-**`skip`** - Specifies that the field should be skipped. This is useful for fields that are not displayed in the table.
92
83
-**`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.
84
+
-**`skip_header`** - Makes the title of the field not be displayed in the head row.
93
85
-**`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"`).
94
86
-**`renderer`** - Specifies the name of the cell renderer component. Used to customize the rendering of cells.
95
87
Defaults to [`DefaultNumberTableCellRenderer`] for number types and [`DefaultTableCellRenderer`] for anything else.
@@ -115,10 +107,9 @@ You can also look at [`TailwindClassesPreset`] for an example how this can be im
// Easy cell renderer that just displays an image from an URL.
219
210
#[component]
220
211
fnImageTableCellRenderer<F>(
221
-
#[prop(into)] class:MaybeSignal<String>,
212
+
class:String,
222
213
#[prop(into)] value:MaybeSignal<String>,
223
214
on_change:F,
224
215
index:usize,
@@ -234,19 +225,19 @@ where
234
225
}
235
226
```
236
227
237
-
For more detailed information please have a look at the `custom_renderers_svg` example for a complete customization.
228
+
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.
238
229
239
230
240
-
####Editable Cells
231
+
### Editable Cells
241
232
242
233
You might have noticed the type parameter `F` in the custom cell renderer above. This can be used
243
234
to emit an event when the cell is changed. In the simplest case you can use a cell renderer that
logging::log!("Changed row at index {}:\n{:#?}", evt.row_index, evt.changed_row);
282
272
};
283
273
284
274
view! {
285
-
<BookTableitems=itemson_change=on_change/>
275
+
<table>
276
+
<TableContentrowson_change/>
277
+
</table>
286
278
}
287
279
}
288
280
```
289
281
290
-
Please have a look at the `editable` example for fully working example.
282
+
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.
283
+
284
+
## Pagination / Virtualization / InfiniteScroll
285
+
286
+
This table component supports different display acceleration strategies. You can set them through the `display_strategy` prop of
287
+
the [`TableContent`] component.
288
+
289
+
The following options are available. Check their docs for more details.
290
+
-[`DisplayStrategy::Virtualization`] (default)
291
+
-[`DisplayStrategy::InfiniteScroll`]
292
+
-[`DisplayStrategy::Pagination`]
293
+
294
+
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