Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: disable sorting and filtering in auto grid columns #3023

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions articles/react/components/auto-grid/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,40 @@
[NOTE]
If the `visibleColumns` property is present, only the custom columns for which their keys are mentioned in the `visibleColumns` are rendered according to the specified order.

== Filtering
== Sorting and Filtering

Auto Grid has column-based filtering enabled by default. You can disable the built-in column filters by setting the `noHeaderFilters` flag.
Auto Grid has sorting and filtering enabled by default for all columns with a supported Java type. That includes all primitive types, like strings, numbers, booleans, as well as some complex types like enums, `java.time.LocalDate` and `java.time.LocalTime`. It automatically sorts by the first column, and shows a filter field in the header of each column.

.Auto Grid using `noHeaderFilters={true}`
You can disable sorting and filtering for individual columns by configuring the `sortable` and `filterable` properties of the column in the `columnOptions` object. This can be useful, for example for columns that show a computed property for which no sorting and filtering is implemented in the `ListService`, or if there simply isn't any meaningful way to sort or filter.

Check warning on line 155 in articles/react/components/auto-grid/index.asciidoc

View workflow job for this annotation

GitHub Actions / vale

[vale] articles/react/components/auto-grid/index.asciidoc#L155

[Vaadin.JustSimply] Avoid using 'simply'. It may be insensitive.
Raw output
{"message": "[Vaadin.JustSimply] Avoid using 'simply'. It may be insensitive.", "location": {"path": "articles/react/components/auto-grid/index.asciidoc", "range": {"start": {"line": 155, "column": 323}}}, "severity": "WARNING"}

.Auto Grid with sorting and filtering disabled for the `displayName` column
[source,tsx]
----
include::{root}/frontend/demo/component/auto-grid/react/auto-grid-no-header-filters.tsx[render,tags=snippet,indent=0,group=React]
<AutoGrid
service={ProductService}
model={ProductModel}
columnOptions={{
displayName: {
filterable: false,
sortable: false,
},
}}
/>
----

Auto Grid supports external filtering by using the criteria specified by the `experimentalFilter` property.
Alternatively, you can disable all header filters by setting the `noHeaderFilters` property.

.Experimental Feature
[WARNING]
External Auto Grid filtering is an experimental feature. The `experimentalFilter` property API may be changed or removed in future releases.
.Auto Grid with all header filters disabled
[source,tsx]
----
<AutoGrid
service={ProductService}
model={ProductModel}
noHeaderFilters
/>
----

As an alternative to the built-in header filters, Auto Grid supports external filtering by passing a custom filter definition to the `experimentalFilter` property.

In the example below, the data in Auto Grid is filtered using the _contains_ matcher for the `name` property, combined with the _equals_ matcher for `category` when a specific category is selected:

Expand All @@ -172,7 +191,11 @@
include::{root}/frontend/demo/component/auto-grid/react/auto-grid-filtering.tsx[render,tags=snippet,indent=0,group=React]
----

You can combine several filtering criteria by using the `{t: 'and' | 'or', children: []}` composite filter type.
You can combine several filtering criteria by using the `{'@type': 'and' | 'or', children: []}` composite filter type.

.Experimental Feature
[WARNING]
External Auto Grid filtering is an experimental feature. The `experimentalFilter` property API may be changed or removed in future releases.

== [since:dev.hilla:[email protected]]#Refreshing Data#

Expand Down

This file was deleted.

Loading