mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
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
28 lines
1.1 KiB
HTML
28 lines
1.1 KiB
HTML
<table>
|
|
<thead>
|
|
<tr>
|
|
{% for column in display_columns %}
|
|
<th scope="col">
|
|
{% if not column.sortable %}
|
|
{{ column.name }}
|
|
{% else %}
|
|
{% if column.name == sort %}
|
|
<a href="{{ path_with_added_args(request, {'_sort_desc': column.name, '_sort': None, '_next': None}) }}" rel="nofollow">{{ column.name }} ▼</a>
|
|
{% else %}
|
|
<a href="{{ path_with_added_args(request, {'_sort': column.name, '_sort_desc': None, '_next': None}) }}" rel="nofollow">{{ column.name }}{% if column.name == sort_desc %} ▲{% endif %}</a>
|
|
{% endif %}
|
|
{% endif %}
|
|
</th>
|
|
{% endfor %}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for row in display_rows %}
|
|
<tr>
|
|
{% for cell in row %}
|
|
<td>{{ cell.value }}</td>
|
|
{% endfor %}
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|