Add simple searchable column support for non-AJAX grids
idk maybe even AJAX grids can use? not gonna try at the moment
This commit is contained in:
parent
63fef16c37
commit
ec2600ddf7
4 changed files with 22 additions and 2 deletions
|
@ -76,6 +76,7 @@ class Grid(object):
|
|||
enums={}, labels={}, assume_local_times=False, renderers={}, invisible=[],
|
||||
extra_row_class=None, linked_columns=[], url='#',
|
||||
joiners={}, filterable=False, filters={}, use_byte_string_filters=False,
|
||||
searchable={},
|
||||
sortable=False, sorters={}, default_sortkey=None, default_sortdir='asc',
|
||||
pageable=False, default_pagesize=20, default_page=1,
|
||||
checkboxes=False, checked=None, check_handler=None, check_all_handler=None,
|
||||
|
@ -119,6 +120,8 @@ class Grid(object):
|
|||
self.use_byte_string_filters = use_byte_string_filters
|
||||
self.filters = self.make_filters(filters)
|
||||
|
||||
self.searchable = searchable or {}
|
||||
|
||||
self.sortable = sortable
|
||||
self.sorters = self.make_sorters(sorters)
|
||||
self.default_sortkey = default_sortkey
|
||||
|
@ -241,6 +244,15 @@ class Grid(object):
|
|||
kwargs['label'] = self.labels[key]
|
||||
self.filters[key] = self.make_filter(key, *args, **kwargs)
|
||||
|
||||
def set_searchable(self, key, searchable=True):
|
||||
if searchable:
|
||||
self.searchable[key] = True
|
||||
else:
|
||||
self.searchable.pop(key, None)
|
||||
|
||||
def is_searchable(self, key):
|
||||
return self.searchable.get(key, False)
|
||||
|
||||
def remove_filter(self, key):
|
||||
self.filters.pop(key, None)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue