Date searching with ColumnControl

Date searching with ColumnControl

JamesHolsonJamesHolson Posts: 7Questions: 2Answers: 0
edited July 17 in Free community support

Link to test case: https://live.datatables.net/lanaxupa/1/edit?js,output
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Good morning. I've been testing the new feature ColumnControl but I've encontered a few issues/questions I'd like to ask.

  1. Searching an exact date doesn't seem to work. If you pick a date for the column "Start date" with the default selection ("Equals"), the table displays no results. It works for "After" and "Before" but not "Equals".

  2. If you pick a date, clear the selection and pick the same date again it doesn't search.

  3. If I add the library "luxon" it messes with the search field after picking a date, as seen in this test case. It's only happening in the test case website, not on my projects so it's not really a problem.

  4. Is it possible to format the date in the search field?

Thanks for the help!

Answers

  • allanallan Posts: 64,757Questions: 1Answers: 10,716 Site admin

    Hi,

    Many thanks for this. I'll look into it in more detail tomorrow. I see the search problem as well, which is surprising - I thought I had unit tests for that!

    Allan

  • JamesHolsonJamesHolson Posts: 7Questions: 2Answers: 0

    Thanks for checking it out!

    I wanted to ask an additional question - is it possible to make 'searchList' accent-insensite?

    I've created this test case to highlight the issue - using normal 'search' (1st column) I'm able to search without accents/diacritics, however with 'searchList' (2nd column) I'm not.

  • JamesHolsonJamesHolson Posts: 7Questions: 2Answers: 0

    Hey Allan,

    I'm sorry for making so many questions... 😅 But it seems 'searchList' also has trouble with special characters - even though they appear correctly in the options list, selecting them yields no results - link to the test case

  • allanallan Posts: 64,757Questions: 1Answers: 10,716 Site admin

    1) It took me an embarrassingly long time to realise that the version of ColumnControl in the example is out of date. Updated from 1.0.2 to the latest (1.0.7) addresses the exact date search issue: https://live.datatables.net/lanaxupa/4/edit .

    2) I think this is also fixed.

    3) Also appears to be fixed with the latest versions - updated test case.

    4) No - the format of the date picker will attempt to match the format of the column (using this function). There isn't currently an option to have the column and the date picker in different formats. I figured that would just confuse users. What's the use case for it?

    5) Do you mean the list search isn't normalising accents? DataTable's own search will normalise accents which is why the "Search" column will allow "Etica" to match "Ética". However, the search for the list isn't that smart, it just does direct string matching, which is what you are seeing in the SearchList. I can look into how complex (or not) it might be to normalise the strings for that inner search.

    6) I see the issue - thank you for the test case (I do like test cases!). There is a divergence between how DataTables core processes the filter data to be cached (and then filtered on) and how ColumnControl does it. I've actually got a bug for something related to this already.

    I'll need to think about this last one a bit more. I hadn't planned to make the change to DataTables until 2.4, but I might need to do something about it before then.

    Allan

  • JamesHolsonJamesHolson Posts: 7Questions: 2Answers: 0

    Thanks for looking into all that!

    1) I didn't notice I used that version in the test case, my apologies. However this seems to be just a coincidence, since I was actually using the version 1.0.7 in my project and the issue was still happening. It's very strange, see in your updated test case - if you search for "2008-09-26" it doesn't return anything, but "2008-12-11" does. I think it might be recognizing the wrong format sometimes (MM-dd and dd-MM), I'm not sure.

    2) Can you confirm? I'm still finding that issue with the 1.0.7 version.

    3) It's fixed.

    4) I was actually trying to match the format - since the table shows yyyy/mm/dd and the input shows yyyy-mm-dd. I see I have to render type === 'datetime', thanks for linking the function.

    5) That's exactly it, I was hoping the search for the list could normalise accents.

    And finally there's something else - if the datepicker search is inside a dropdown ( content: [[ 'search' ]] ) selecting another year or month moves the datepicker to the top left corner of the page - I'm assuming because the dropdown modal loses focus and closes - see the test case

    Thanks a lot for the help :)

  • allanallan Posts: 64,757Questions: 1Answers: 10,716 Site admin

    1) If you search for "2008/09/26" (i.e. / rather than -, which matches the data) then the exact match works. It turns out that new Date() has different behaviour for / from -. It treats the former input as local time, while the later is UTC.

    For the search, I want to treat them as the same, so I've added a little replace to have them all with - form.

    2) No you are right - I can see that error as well - I wasn't quite on the right wavelength before.

    7) Yes, that closing of the dropdown is wrong and is a bug I'll need to address. Thanks for finding and letting me know about that.

    2 and 7 will need to wait until next week at this point I'm afraid - probably Tuesday.

    Allan

Sign In or Register to comment.