Skip to content

Commit

Permalink
Fixed bug with filter columns
Browse files Browse the repository at this point in the history
Closes #162
  • Loading branch information
simonw committed Dec 7, 2017
1 parent 709f4f2 commit 52a5e95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 5 additions & 0 deletions datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,13 @@ async def data(self, request, name, hash, table):
rows = list(rows)

display_columns = columns
filter_columns = columns
if not use_rowid and not is_view:
display_columns = ['Link'] + display_columns

if use_rowid and filter_columns[0] == 'rowid':
filter_columns = filter_columns[1:]

info = self.ds.inspect()
table_rows = None
if not is_view:
Expand Down Expand Up @@ -670,6 +674,7 @@ async def extra_template():
'use_rowid': use_rowid,
'filters': filters,
'display_columns': display_columns,
'filter_columns': filter_columns,
'display_rows': await self.make_display_rows(name, hash, table, rows, display_columns, pks, is_view, use_rowid),
}

Expand Down
12 changes: 4 additions & 8 deletions datasette/templates/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ <h3>{% if filtered_table_rows or filtered_table_rows == 0 %}{{ "{:,}".format(fil
<div class="select-wrapper">
<select name="_filter_column_{{ loop.index }}">
<option value="">- remove filter -</option>
{% for c in display_columns %}
{% if c != 'rowid' %}
<option{% if c == column %} selected{% endif %}>{{ c }}</option>
{% endif %}
{% for c in filter_columns %}
<option{% if c == column %} selected{% endif %}>{{ c }}</option>
{% endfor %}
</select>
</div><div class="select-wrapper filter-op">
Expand All @@ -54,10 +52,8 @@ <h3>{% if filtered_table_rows or filtered_table_rows == 0 %}{{ "{:,}".format(fil
<div class="select-wrapper">
<select name="_filter_column">
<option value="">- column -</option>
{% for column in display_columns %}
{% if column != 'rowid' %}
<option>{{ column }}</option>
{% endif %}
{% for column in filter_columns %}
<option>{{ column }}</option>
{% endfor %}
</select>
</div><div class="select-wrapper filter-op">
Expand Down

0 comments on commit 52a5e95

Please sign in to comment.