Closed digrigor closed 4 years ago
Solved!
To help people who might face the same problem, the solution was: 1) To define search methods when using the ColumnDT. For example: columns = [ ColumnDT(User.id, search_method="yadcf_range_number"), ColumnDT(User.name, search_method="yadcf_multi_select"), ColumnDT(Address.description, search_method="yadcf_autocomplete"), ColumnDT(User.birthday, search_method="yadcf_range_date"), ColumnDT(User.age, search_method="yadcf_range_number_slider") ]
2) And follow author's instruction when defining the query: defining the initial query depending on your purpose
Thanks for developing this really helpful framework :)
Since you brought it up, I thought I'd mention that with mysql I had to monkeypatch the range number search method. I didn't provide this as a pull request as I don't know how this affects other database engines.
# monkey patch yadcf_range_number search method
def alt_yadcf_range_number(expr, value):
v_from, v_to = value.split('-yadcf_delim-')
v_from = float(v_from) if v_from != '' else -sys.maxsize+1 # was float('-inf')
v_to = float(v_to) if v_to != '' else sys.maxsize # was float('inf')
# logger.debug('yadcf_range_number: between %f and %f', v_from, v_to)
return expr.between(v_from, v_to)
from datatables.search_methods import SEARCH_METHODS
SEARCH_METHODS['yadcf_range_number'] = alt_yadcf_range_number
Hi,
Thanks for developing this really useful tool.
I have managed to connect an sqlite3 to my flask application and visualise it with datatables by following your really nice flask example. I have also managed to add the yadcf functionallity.
The problem I am mostly facing is when I am using multi-select and range filters. With multi-select when I am only selecting 1 value everything works as expected. When I select 2 values, 0 rows are being returned. I also get 0 rows returned when I use the number-range filter for integers or real numbers columns.
I guess this has to do with the way the filters are being passed to the server-side. Is there any way I can control that?
Do you have any thoughts on this? Thanks again for helping! :)
Best, Dionysios