diff --git a/tailbone/grids/core.py b/tailbone/grids/core.py index 0baa7ab9..ba988689 100644 --- a/tailbone/grids/core.py +++ b/tailbone/grids/core.py @@ -996,6 +996,22 @@ class Grid(object): return render(template, context) + def set_filters_sequence(self, filters): + """ + Explicitly set the sequence for grid filters, using the sequence + provided. If the grid currently has more filters than are mentioned in + the given sequence, the sequence will come first and all others will be + tacked on at the end. + + :param filters: Sequence of filter keys, i.e. field names. + """ + new_filters = gridfilters.GridFilterSet() + for field in filters: + new_filters[field] = self.filters.pop(field) + for field in self.filters: + new_filters[field] = self.filters[field] + self.filters = new_filters + def get_filters_sequence(self): """ Returns a list of filter keys (strings) in the sequence with which they