serverSide + SearchBuilder + luxon throwing a type error

serverSide + SearchBuilder + luxon throwing a type error

arthur_taxcyclearthur_taxcycle Posts: 4Questions: 1Answers: 0

Link to test case: http://live.datatables.net/pajijiha/1/
Debugger code (debug.datatables.net): https://debug.datatables.net/amejav
Error messages shown: Uncaught TypeError: Cannot read properties of null (reading 'toString')
Description of problem:
When serverSide is set to true and the time zone token is included in the searchBuilderType eg: luxon-MM/dd/yyyy hh:mm:ss ZZZZ, an error is thrown.

  1. Click on Add Condition
  2. Set Data to Start date
  3. Pick any condition
  4. Pick a date/time
  5. An error is thrown

A workaround is to simply drop the timezone token from the format string or use ZZ which works fine. Is this a limitation that should be documented or a bug that needs to be fixed?

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @arthur_taxcycle ,

    I've updated your example to use the latest nightly build for SearchBuilder. This just makes things a bit easier to debug.

    The issue here is that the DateTime picker for me is producing GMT+1. This is not a format that Luxon is able to parse, but it is a valid timezone. I've raised an issue internally (DD-2359 for my reference) and will report back here when there is an update.

    Thanks,
    Sandy

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @arthur_taxcycle ,

    I've discussed with Allan and at the moment DateTime is only compatible with UTC. We do have some ideas to make it possible to use timezones properly in the future, but at the moment this is not possible. If you can manage without using timezones then that is the way to do it.

    Thanks,
    Sandy

  • arthur_taxcyclearthur_taxcycle Posts: 4Questions: 1Answers: 0

    Hello,

    Is there a way to show date/time on the UI but epoch timestamp in a string when sending the data? Do I need to hook into the ajax call?

    Also possibly related, datatables.ajax.reload() also throws an exception regardless of whether the timezone is in the format or not. Here is the sandbox link.

    Thanks,

    Arthur

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    You should be able to use orthogonal data for that different rendering to what was sent - see example here.

    I'm not sure about the ajax.reload() error - your test case doesn't generate an error for me. Can you link to a test case that demonstrates the error, please.

    Colin

  • arthur_taxcyclearthur_taxcycle Posts: 4Questions: 1Answers: 0
    edited November 2021

    Hello,

    I apologize for not including the entire reproduction steps.

    1. Click Add Condition
    2. Set Data to Start Date
    3. Set Condition to Before/After
    4. Set a value
    5. Click Reload
    TypeError: Cannot read properties of null (reading 'match')
        at https://cdnjs.cloudflare.com/ajax/libs/luxon/2.0.2/luxon.min.js:1:48610
        at Sn (https://cdnjs.cloudflare.com/ajax/libs/luxon/2.0.2/luxon.min.js:1:48791)
        at Function.w.fromFormat (https://cdnjs.cloudflare.com/ajax/libs/luxon/2.0.2/luxon.min.js:1:58332)
        at c.getDetails (https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.11.3/b-2.0.1/b-colvis-2.0.1/b-html5-2.0.1/b-print-2.0.1/cr-1.5.4/date-1.1.1/fc-4.0.0/fh-3.2.0/r-2.2.9/rg-1.1.3/sc-2.0.5/sb-1.2.2/sp-1.4.0/sl-1.3.3/datatables.min.js:704:493)
        at c.getDetails (https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.11.3/b-2.0.1/b-colvis-2.0.1/b-html5-2.0.1/b-print-2.0.1/cr-1.5.4/date-1.1.1/fc-4.0.0/fh-3.2.0/r-2.2.9/rg-1.1.3/sc-2.0.5/sb-1.2.2/sp-1.4.0/sl-1.3.3/datatables.min.js:779:304)
        at c.getDetails (https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.11.3/b-2.0.1/b-colvis-2.0.1/b-html5-2.0.1/b-print-2.0.1/cr-1.5.4/date-1.1.1/fc-4.0.0/fh-3.2.0/r-2.2.9/rg-1.1.3/sc-2.0.5/sb-1.2.2/sp-1.4.0/sl-1.3.3/datatables.min.js:801:136)
        at HTMLTableElement.<anonymous> (https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.11.3/b-2.0.1/b-colvis-2.0.1/b-html5-2.0.1/b-print-2.0.1/cr-1.5.4/date-1.1.1/fc-4.0.0/fh-3.2.0/r-2.2.9/rg-1.1.3/sc-2.0.5/sb-1.2.2/sp-1.4.0/sl-1.3.3/datatables.min.js:805:111)
        at HTMLTableElement.dispatch (https://code.jquery.com/jquery-3.4.1.min.js:2:42571)
        at HTMLTableElement.v.handle (https://code.jquery.com/jquery-3.4.1.min.js:2:40572)
        at Object.trigger (https://code.jquery.com/jquery-3.4.1.min.js:2:70627)"
    

    A similar issue occurs when using the moment library. live.datatables.net/kotuyuxu/1/edit

    Uncaught TypeError: Cannot read properties of null (reading 'toString')
        at datatables.min.js:705
        at Array.map (<anonymous>)
        at c.getDetails (datatables.min.js:705)
        at c.getDetails (datatables.min.js:779)
        at c.getDetails (datatables.min.js:801)
        at HTMLTableElement.<anonymous> (datatables.min.js:805)
        at HTMLTableElement.dispatch (jquery-3.4.1.min.js:2)
        at HTMLTableElement.v.handle (jquery-3.4.1.min.js:2)
        at Object.trigger (jquery-3.4.1.min.js:2)
        at HTMLTableElement.<anonymous> (jquery-3.4.1.min.js:2)
    
  • arthur_taxcyclearthur_taxcycle Posts: 4Questions: 1Answers: 0

    Hello all,

    Thanks for your help! I was able to debug and fix the issues I was experiencing with the searchbuilder extension.

    The change can be found here.

    Regards,

    Arthur

Sign In or Register to comment.