django-ajax-datatable icon indicating copy to clipboard operation
django-ajax-datatable copied to clipboard

Filter DateTimeField as a string

Open michaeldacanay opened this issue 1 year ago • 3 comments

The column search box does not work for DateTimeField. For example, intuitively a column with value 08/07/2017 17:03:28 should match "8/07" or "2017". However, the table becomes empty and "No data available in table" is displayed instead. Is there a way to treat the date as a string, similar to how foreign_field option allowed for filtering a foreign key?

michaeldacanay avatar Mar 13 '23 23:03 michaeldacanay

Have you tried with full date ? 08/08/2017 ? Works for me.. image

cnagytcorp avatar Mar 14 '23 00:03 cnagytcorp

It doesn't filter when using the column search box. But there is some other weird behavior:

  • The date displayed in the column is different from the date that appears in the inner table that displays when I click on the row. Update: The date in the column is PST, while the date in the inner table is UTC.
  • Some columns seem to only update when there is a matching string literal. But if I type something that doesn't seem to match any value, it just doesn't filter
  • The overall search bar is not filtering

I will debug and see if it is an issue with my configuration/setup.

michaeldacanay avatar Mar 14 '23 18:03 michaeldacanay

For example, if a date model has a field:

created_date = models.DateTimeField(auto_now_add=True)

The value in the inner table looks like "2022-09-15 18:32:27+00:00". I tried 2022-09-15, 09/15/2022, even the full date string but all don't work. Additionally, if I make the column a select drop-down, it does not seem to match any records. image

michaeldacanay avatar Mar 18 '23 01:03 michaeldacanay