horizon server filter results pagination
I was tinkering around with creating a new panel in horizon. I have a server-side filter on the data table, and the results are paginated. Both the filter and pagination work fine when used alone, but when I filter a table, then get the next page of the results, the filter details are not carried along. Is there is a horizon-native way to persist the filter field and value?
Here's my filter action class to help clarify what's going on.
class MyFilterAction(tables.FilterAction):
param_name = 'logs_filter'
filter_type = 'server'
filter_choices = (('message', _("Message"), True),
('syslog_severity', _("Severity"), True),
('component', _("Component"), True),
('host', _("Host"), True))
Then my tab looks something like this:
class LogsTab(tabs.TableTab):
name = _("Logs Tab")
slug = "logs_tab"
table_classes = (tables.LogsTable,)
template_name = ("horizon/common/_detail_table.html")
preload = False
....
def get_logs_data(self):
try:
marker = self.request.GET.get(
tables.LogsTable._meta.pagination_param, None)
filter_field = self.request.POST.get(
'logs__filter__logs_filter_field', None)
filter_exp = self.request.POST.get(
'logs__filter__logs_filter', None)
token = self.authenticate_goldstone()
logs = self.get_goldstone_logs(token, marker,
filter_field, filter_exp)
self._has_more = logs['next'] is not None
return logs['results']
except Exception:
self._has_more = False
error_message = _('Unable to get logs')
exceptions.handle(self.request, error_message)
return []
Seems like I could hack into the pagination handler to also pass along filter information, but though I would check with y'all to see if it's been done already.
Hi, Also trying to tinker around with the filter. Just wondering, why is it necessary to have the server side filtering approach instead of a client based filter that is achieved without reloading of the page