diff --git a/src/wuttaweb/grids/filters.py b/src/wuttaweb/grids/filters.py index 170fbd9..54fce1c 100644 --- a/src/wuttaweb/grids/filters.py +++ b/src/wuttaweb/grids/filters.py @@ -189,6 +189,10 @@ class GridFilter: # pylint: disable=too-many-instance-attributes self.app = self.config.get_app() self.label = label or self.app.make_title(self.key) + # remember original data type in case we need to revert, + # e.g. after changing it to 'choices' and back again + self.original_data_type = self.data_type + # active self.default_active = default_active self.active = self.default_active @@ -201,7 +205,7 @@ class GridFilter: # pylint: disable=too-many-instance-attributes self.verb = None # active verb is set later # choices - self.set_choices(choices or {}) + self.set_choices(choices) # nullable self.nullable = nullable @@ -304,7 +308,8 @@ class GridFilter: # pylint: disable=too-many-instance-attributes self.data_type = "choice" else: self.choices = {} - self.data_type = "string" + if self.data_type == "choice": + self.data_type = self.original_data_type def normalize_choices(self, choices): """