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 to load data from a REST API or a database etc.
18
+
-**Async data loading** - The data is loaded asynchronously. This allows to load data from a REST API or a database
19
+
etc.
19
20
-**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.
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.
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.
21
+
-**Customization** - You can customize every aspect of the table by plugging in your own components for rendering rows,
22
+
cells, headers. See [Custom Renderers](#custom-renderers) for more information.
23
+
-**Headless** - No default styling is applied to the table. You can fully customize the classes that are applied to the
24
+
table. See [Classes customization](#classes-customization) for more information.
25
+
-**Sorting** - Optional. If turned on: Click on a column header to sort the table by that column. You can even sort by
26
+
multiple columns.
23
27
-**Virtualization** - Only the visible rows are rendered. This allows for very large tables.
24
28
-**Pagination** - Instead of virtualization you can paginate the table.
25
29
-**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.
30
+
-**Editing** - Optional. You can provide custom renderers for editable cells. See [Editable Cells](#editable-cells) for
31
+
more information.
27
32
28
33
## Usage
29
34
@@ -58,7 +63,8 @@ fn main() {
58
63
59
64
## Server-Side Rendering
60
65
61
-
To use this with Leptos' server-side rendering, you can have to add `leptos-use` as a dependency to your `Cargo.toml` and
66
+
To use this with Leptos' server-side rendering, you can have to add `leptos-use` as a dependency to your `Cargo.toml`
67
+
and
62
68
then configure it for SSR like the following.
63
69
64
70
```toml
@@ -78,7 +84,8 @@ ssr = [
78
84
]
79
85
```
80
86
81
-
Please see the [serverfn_sqlx example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/serverfn_sqlx/Cargo.toml)
87
+
Please see
88
+
the [serverfn_sqlx example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/serverfn_sqlx/Cargo.toml)
82
89
for a working project with SSR.
83
90
84
91
## Data Providers
@@ -93,8 +100,10 @@ Which of the two traits you choose depends on your data source. If your data sou
93
100
paginated data, as is the case for many REST APIs, you should implement [`PaginatedTableDataProvider`].
94
101
Otherwise you should probably implement [`TableDataProvider`].
95
102
96
-
See the [paginated_rest_datasource example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/paginated_rest_datasource/src/data_provider.rs)
97
-
and the [serverfn_sqlx example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/serverfn_sqlx/src/data_provider.rs)
103
+
See
104
+
the [paginated_rest_datasource example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/paginated_rest_datasource/src/data_provider.rs)
105
+
and
106
+
the [serverfn_sqlx example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/serverfn_sqlx/src/data_provider.rs)
98
107
for working demo projects that implement these traits.
99
108
100
109
## Macro options
@@ -105,44 +114,71 @@ The `#[table(...)]` attribute can be used to customize the generated component.
105
114
106
115
These attributes can be applied to the struct itself.
107
116
108
-
-**`sortable`** - Specifies that the table should be sortable. This makes the header titles clickable to control sorting.
109
-
You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
110
-
-`sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by priority.
111
-
-`sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another column will simply replace the sorting column.
112
-
See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) and the
113
-
[selectable example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/selectable/src/main.rs) for more information.
114
-
-**`classes_provider`** - Specifies the name of the class provider. Used to quickly customize all of the classes that are applied to the table.
115
-
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.
116
-
-**`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.
117
-
-**`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>` to allow
118
-
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.
119
-
-**`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.
117
+
-**`sortable`** - Specifies that the table should be sortable. This makes the header titles clickable to control
118
+
sorting.
119
+
You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
120
+
-`sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by
121
+
priority.
122
+
-`sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another
123
+
column will simply replace the sorting column.
124
+
See
125
+
the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs)
-**`classes_provider`** - Specifies the name of the class provider. Used to quickly customize all of the classes that
130
+
are applied to the table.
131
+
For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`]
132
+
and [tailwind example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/tailwind/src/main.rs)
133
+
for more information.
134
+
-**`head_cell_renderer`** - Specifies the name of the header cell renderer component. Used to customize the rendering
135
+
of header cells. Defaults to [`DefaultTableHeaderRenderer`]. See
136
+
the [custom_renderers_svg example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/custom_renderers_svg/src/main.rs)
137
+
for more information.
138
+
-**`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>`
139
+
to allow
140
+
for easy local data use. See
141
+
the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for
142
+
more information.
143
+
-**`row_type`** - Specifies the type of the rows in the table. Defaults to the struct that this is applied to. See
144
+
the [custom_type example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_type/src/main.rs)
145
+
for more information.
120
146
121
147
### Field attributes
122
148
123
149
These attributes can be applied to any field in the struct.
124
150
125
-
-**`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.
126
-
-**`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.
127
-
-**`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.
128
-
-**`skip`** - Specifies that the field should be skipped. This is useful for fields that are not displayed in the table.
129
-
-**`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.
151
+
-**`class`** - Specifies the classes that are applied to each cell (head and body) in the field's column. Can be used
152
+
in conjuction with `classes_provider` to customize the classes.
153
+
-**`head_class`** - Specifies the classes that are applied to the header cell in the field's column. Can be used in
154
+
conjuction with `classes_provider` to customize the classes.
155
+
-**`cell_class`** - Specifies the classes that are applied to the body cells in the field's column. Can be used in
156
+
conjuction with `classes_provider` to customize the classes.
157
+
-**`skip`** - Specifies that the field should be skipped. This is useful for fields that are not displayed in the
158
+
table.
159
+
-**`skip_sort`** - Only applies if `sortable` is set on the struct. Specifies that the field should not be used for
160
+
sorting. Clicking it's header will not do anything.
130
161
-**`skip_header`** - Makes the title of the field not be displayed in the head row.
131
-
-**`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"`).
162
+
-**`title`** - Specifies the title that is displayed in the header cell. Defaults to the field name converted to title
163
+
case (`this_field` becomes `"This Field"`).
132
164
-**`renderer`** - Specifies the name of the cell renderer component. Used to customize the rendering of cells.
133
-
Defaults to [`DefaultTableCellRenderer`].
134
-
-**`format`** - Quick way to customize the formatting of cells without having to create a custom renderer. See [Formatting](#formatting) below for more information.
135
-
-**`getter`** - Specifies a method that returns the value of the field instead of accessing the field directly when rendering.
165
+
Defaults to [`DefaultTableCellRenderer`].
166
+
-**`format`** - Quick way to customize the formatting of cells without having to create a custom renderer.
167
+
See [Formatting](#formatting) below for more information.
168
+
-**`getter`** - Specifies a method that returns the value of the field instead of accessing the field directly when
169
+
rendering.
136
170
-**`none_value`** - Specifies a display value for `Option` types when they are `None`. Defaults to empty string
137
171
138
172
#### Formatting
139
173
140
-
The `format` attribute can be used to customize the formatting of cells. It is an easier alternative to creating a custom renderer when you just want to customize some basic formatting.
141
-
It is type safe and tied to the type the formatting is applied on. see [`CellValue`] and the associated type for the type you are rendering to see a list of options
174
+
The `format` attribute can be used to customize the formatting of cells. It is an easier alternative to creating a
175
+
custom renderer when you just want to customize some basic formatting.
176
+
It is type safe and tied to the type the formatting is applied on. see [`CellValue`] and the associated type for the
177
+
type you are rendering to see a list of options
142
178
143
179
See:
144
-
-[`cell_value::NumberRenderOptions`]
145
180
181
+
-[`cell_value::NumberRenderOptions`]
146
182
147
183
## Features
148
184
@@ -154,7 +190,8 @@ See:
154
190
## Classes Customization
155
191
156
192
Classes can be easily customized by using the `classes_provider` attribute on the struct.
157
-
You can specify any type that implementats the trait [`TableClassesProvider`]. Please see the documentation for that trait for more information.
193
+
You can specify any type that implementats the trait [`TableClassesProvider`]. Please see the documentation for that
194
+
trait for more information.
158
195
You can also look at [`TailwindClassesPreset`] for an example how this can be implemented.
159
196
160
197
Example:
@@ -226,14 +263,17 @@ value you want to modify before it's rendered.
226
263
## Custom Renderers
227
264
228
265
Custom renderers can be used to customize almost every aspect of the table.
229
-
They are specified by using the various `...renderer` attributes on the struct or fields or props of the [`TableContent`] component.
266
+
They are specified by using the various `...renderer` attributes on the struct or fields or props of the [
267
+
`TableContent`] component.
230
268
To implement a custom renderer please have a look at the default renderers listed below.
231
269
232
270
On the struct level you can use this attribute:
271
+
233
272
-**`thead_cell_renderer`** - Defaults to [`DefaultTableHeaderCellRenderer`] which renders `<th><span>Title</span></th>`
234
-
together with sorting functionality (if enabled).
273
+
together with sorting functionality (if enabled).
235
274
236
275
As props of the [`TableContent`] component you can use the following:
276
+
237
277
-**`thead_renderer`** - Defaults to [`DefaultTableHeadRenderer`] which just renders the tag `thead`.
238
278
-**`thead_row_renderer`** - Defaults to [`DefaultTableHeadRowRenderer`] which just renders the tag `tr`.
239
279
-**`tbody_renderer`** - Defaults to the tag `tbody`. Takes no attributes.
@@ -245,7 +285,8 @@ As props of the [`TableContent`] component you can use the following:
245
285
On the field level you can use the **`renderer`** attribute.
246
286
247
287
It defaults to [`DefaultTableCellRenderer`]
248
-
Works for any type that implements the [`CellValue`] trait that is implemented for types in the standard library, popular crates with feature flags and for your own type if you implement this trait for them.
288
+
Works for any type that implements the [`CellValue`] trait that is implemented for types in the standard library,
289
+
popular crates with feature flags and for your own type if you implement this trait for them.
249
290
250
291
Example:
251
292
@@ -276,8 +317,9 @@ where
276
317
}
277
318
```
278
319
279
-
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.
280
-
320
+
For more detailed information please have a look at
321
+
the [custom_renderers_svg example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_renderers_svg/src/main.rs)
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.
375
+
Please have a look at
376
+
the [editable example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/editable/src/main.rs) for
377
+
fully working example.
334
378
335
379
## Pagination / Virtualization / InfiniteScroll
336
380
337
-
This table component supports different display acceleration strategies. You can set them through the `display_strategy` prop of
381
+
This table component supports different display acceleration strategies. You can set them through the `display_strategy`
382
+
prop of
338
383
the [`TableContent`] component.
339
384
340
385
The following options are available. Check their docs for more details.
386
+
341
387
-[`DisplayStrategy::Virtualization`] (default)
342
388
-[`DisplayStrategy::InfiniteScroll`]
343
389
-[`DisplayStrategy::Pagination`]
344
390
345
-
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.
391
+
Please have a look at
392
+
the [pagination example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/pagination/src/main.rs)
393
+
for more information on how to use pagination.
346
394
347
395
## I18n
348
396
@@ -365,4 +413,4 @@ All contributions are welcome. Please open an issue or a pull request if you hav
0 commit comments