SearchBuilder does not persist date format when reloading

SearchBuilder does not persist date format when reloading

mtdevmtdev Posts: 13Questions: 2Answers: 1

Link to test case: http://live.datatables.net/lazijigi/1/edit
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Hello,

In SearchBuilder, with moment.js, server-side, and state save, I have found an issue with date handling : no matter what date format is configured, the SearchBuilder replaces the value (internally) by the UTC format, for next use (next AJAX request, next "stateSave" or page reload).

Steps to reproduce :
1) Click Add condition, select Start date data, the Equals condition, and choose a date in the calendar. Ex: the day 18 of July of the year 2022.
2) The value in the input HTML element is 18th Jul 22 : it is OK.
3) Reload the page : the SearchBuilder predefined value is now : 2022-07-18 00:00:00 (displayed in the field)

Expected :
On reload, the expected value into the input for start date is 18th Jul 22.

Between steps 2 and 3, you can check the GET parameters of the server-side request: the format is UTC. But this behavior seems to be expected, according to the source code of searchbuilder.js.

But this code definitely replaces the value property of the Criteria object by the UTC value. So, with the stateSave behaviour, this is the UTC that is kept in local storage, and when reloading the page the predefined value is displayed as UTC.

Is there a way so that the SearchBuilder convert (back) the UTC value to the configured date format when rebuilding the filter fields ?

Regards.

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 14,458Questions: 1Answers: 2,464
    Answer ✓

    That's a convincing test case, thanks for creating that. I've raised it internally (DD-2573 for my reference) and we'll report back here when there's an update.

    Cheers,

    Colin

  • mtdevmtdev Posts: 13Questions: 2Answers: 1

    You're welcome.
    Regards.

    PS : Always on SearchBuilder, I have write this post (SearchBuilder) "serverData" breaks the expected behavior when updating data select : if it is confusing or not clear enough, I can write another, simpler / step by step. Just tell me.

  • colincolin Posts: 14,458Questions: 1Answers: 2,464
    Answer ✓

    I'll leave that one for Allan :)

    Colin

Sign In or Register to comment.