Skip to content
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
2 changes: 1 addition & 1 deletion src/webgrid/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def filtering_col_label(self, col):
def filtering_col_op_select(self, col):
"""Render select box for filter Operator options."""
filter = col.filter
current_selected = '' if filter.is_display_active else filter.op
current_selected = filter.op if filter.is_display_active else ''

primary_op = filter.primary_op or filter.operators[0]
is_primary = lambda op: 'primary' if op == primary_op else None
Expand Down
14 changes: 14 additions & 0 deletions tests/webgrid_tests/test_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,20 @@ class TGrid(Grid):
filter_html = tg.html.filtering_fields()
assert '<input id="search_input"' not in filter_html

@_inrequest('/thepage?op(firstname)=contains&v1(firstname)=Fred')
def test_filtering_operator_selected(self):
g = PeopleGrid()
g.apply_qs_args()

pyq = PyQuery(g.html())

# Ensures the op we have in the URL is valid. If it wasn't valid, webgrid would not render
# a value for input1.
assert pyq('#firstname_input1').val() == 'Fred'

selected_opts = pyq('tr.firstname_filter td.operator option[selected]')
assert selected_opts.val() == 'contains'


class PGPageTotals(PeopleGrid):
subtotals = 'page'
Expand Down
Loading