Date filter for a repeating panel and autocomplete form

thanks to the help of the forum my app is working great, but i was requested to add 2 features to the app

the first one is that I need the option to filter the elements of the table by date and display them on the repeating row.

the second one is in the form, if i have ever filled the form with a plate number and save it, it has to find it and automatically fill some of the data of the corresponding plate number

1 Like

For the date filtering, you want the query operators. The blog post is still the best reference for those, here: Querying Data Tables

It isn’t exactly intuitive how to have flexible sets of queries, though, so I’ll share a technique I use. In the following code, you can pass in a start date and end date, and either value is optional.

  queries = [q.none_of()]
  
  if start_date:
    queries.append(q.any_of(created=q.greater_than_or_equal_to(start_date)))

  if end_date:
    queries.append(q.any_of(created=q.less_than_or_equal_to(end_date)))

  results = app_tables.activity.search(q.all_of(*queries))

You can combine that with other more specific parameters, too, for example to limit the results by user:

  results = app_tables.activity.search(q.all_of(*queries), user=anvil.users.get_user())
1 Like