mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
New sortable_columns option in metadata.json to control sort options
You can now explicitly set which columns in a table can be used for sorting
using the _sort and _sort_desc arguments using metadata.json:
{
"databases": {
"database1": {
"tables": {
"example_table": {
"sortable_columns": [
"height",
"weight"
]
}
}
}
}
}
Refs #189
This commit is contained in:
parent
a87df963a0
commit
b13f0986f2
7 changed files with 93 additions and 23 deletions
|
|
@ -55,6 +55,33 @@ You can also provide metadata at the per-database or per-table level, like this:
|
|||
|
||||
Each of the top-level metadata fields can be used at the database and table level.
|
||||
|
||||
Setting which columns can be used for sorting
|
||||
---------------------------------------------
|
||||
|
||||
Datasette allows any column to be used for sorting by default. If you need to
|
||||
control which columns are available for sorting you can do so using the optional
|
||||
``sortable_columns`` key::
|
||||
|
||||
{
|
||||
"databases": {
|
||||
"database1": {
|
||||
"tables": {
|
||||
"example_table": {
|
||||
"sortable_columns": [
|
||||
"height",
|
||||
"weight"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
This will restrict sorting of ``example_table`` to just the ``height`` and
|
||||
``weight`` columns.
|
||||
|
||||
You can also disable sorting entirely by setting ``"sortable_columns": []``
|
||||
|
||||
Generating a metadata skeleton
|
||||
------------------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue