Add Grid.set_filters_sequence()
convenience method
sometimes a properly-ordered filter sequence can really help
This commit is contained in:
parent
3895734c32
commit
8947a4d14f
|
@ -996,6 +996,22 @@ class Grid(object):
|
||||||
|
|
||||||
return render(template, context)
|
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):
|
def get_filters_sequence(self):
|
||||||
"""
|
"""
|
||||||
Returns a list of filter keys (strings) in the sequence with which they
|
Returns a list of filter keys (strings) in the sequence with which they
|
||||||
|
|
Loading…
Reference in a new issue