-
Notifications
You must be signed in to change notification settings - Fork 63
Description
I'm having trouble lining up the self.columns index with the index which comes from datatables(js) in the search item. My indexes don't match sometimes because I have to post process the output_result to get an object like field: {id:idval, label:labelval} which is expected by datatables(js). Possibly this object can be returned directly by sqlalchemy-datatables but after several days of research I haven't been able to find the magic elixir to make that work.
example response snippet
columns[4][data]: assignee.name
columns[4][name]: assignee.name
columns[4][searchable]: true
columns[4][orderable]: true
columns[4][search][value]: Lou King
columns[4][search][regex]: true
Is there a reason you're assuming the datatables(js) index (4) matches the sqlalchemy-datatables index, rather than matching the configured mData with the data from the query parameter columns[4][data]: assignee.name in this case assignee.name?
E.g., see use of index in
sqlalchemy-datatables/datatables/datatables.py
Lines 140 to 148 in 049ab5f
| # per columns filters: | |
| for i in range(len(self.columns)): | |
| filter_expr = None | |
| value = self.params.get('columns[{:d}][search][value]'.format(i), | |
| '') | |
| if value: | |
| search_func = SEARCH_METHODS[self.columns[i].search_method] | |
| filter_expr = search_func(self.columns[i].sqla_expr, value) | |
| self.filter_expressions.append(filter_expr) |