Problem with date type on 3.0 update

Problem with date type on 3.0 update

coreyg142coreyg142 Posts: 20Questions: 1Answers: 0

Getting around to updating my projects to 3.0, I've encountered an issue where a server-side rendered table with a date column gets into an infinite loop of updating the data.

Example here: https://stackblitz.com/edit/koj9creq-qd2zsh1k?file=src%2FApp.vue

To trigger it simply do anything that would trigger a serverside update, (sort columns, search, change page, etc) and you should see what I mean.

This does not happen on the previous versions. It also does not happen if the date column is removed, or set to a different type.

Also curious if you've had a chance to take a look at my other issue: https://datatables.net/forums/discussion/81829/colreorder-does-not-work-properly-with-vue-when-ordering-slot-rendered-columns

No worries if not, I know it's probably been a super busy week for you!

Replies

  • allanallan Posts: 65,856Questions: 1Answers: 10,956 Site admin

    Interesting - thank you for spotting that and bringing it to my attention. I'm not immediately sure what is causing it, but something will be calling the draw() method, probably in a resize update I guess. I will dig into that and get back to you.

    Also, no, I haven't forgotten about the Vue issue. Apologies I haven't gotten to that this week. I'm going to take a little down time next week, but I will look at that issue, probably the following week, as that is something that should very much work.

    Allan

  • lbermudezlbermudez Posts: 5Questions: 0Answers: 0

    I have the same problem when using columnControl with server side on date type. (not using vue).

    Putting a valid date on the column search stops the loop but if i clear the value it starts again.

    Seems to happen only with columncontrol.

  • allanallan Posts: 65,856Questions: 1Answers: 10,956 Site admin

    I've committed a fix for this issue. The problem is demonstrated with ColumnControl as @lbermudez correctly points out, but it is just the trigger for what was an issue in DataTables core.

    The fix is now in the nightly builds and I would very much welcome if either (or both!) of you could try it out and confirm that addresses the problem you were seeing.

    Regards,
    Allan

  • lbermudezlbermudez Posts: 5Questions: 0Answers: 0

    Can confirm that the trigger is no longer causing the loop.
    Sorting now works flawlessly,

    But now i think the search is not autodetecting the date format, im using EU format, and:

    13/08/2026 returns a blank list
    2026-08-13 return the full list (no filter)

        Field::inst('demo.fecha_hora', 'fecha_hora')
            ->getFormatter(Format::dateSqlToFormat('d/m/Y H:i'))
            ->setFormatter(Format::dateFormatToSql('d/m/Y H:i')),
    
        Field::inst('demo.fecha_hora', 'fecha')
            ->getFormatter(Format::dateSqlToFormat('d/m/Y' ))
            ->setFormatter(Format::dateFormatToSql('d/m/Y')),
    
    
    
    
    DataTable.use(moment, 'moment');
    DataTable.datetime('DD/MM/YYYY');
    DataTable.datetime('DD/MM/YYYY HH:mm');
    
    
               {
                        data: 'fecha_hora',
                        title: 'FechaHora',
    
                        columnControl: {
                            target: 0,
                            content: [
                                'order',
                                ['searchDateTime']
                            ]
                        }
                    },
                    {
                        data: 'fecha',
                        title: 'Fecha',
                        columnControl: {
                            target: 0,
                            content: [
                                'order',
                                ['searchDateTime']
                            ]
                        }
                    },
    

    But this might be a problem on my side, since i have done so many tests that my dependences are a mess.
    I'll try more during the week.

    Also, just a side note, if i try to leave target 0 empty (on both elements), by targeting the column index 1. I get an error (im gessing because the second column is not created) this is not that important but prevents using the native sort (since it will disappear from all columns if columncontrol.order is defined in one of them.

    Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '2')

    Thanks for your dedication, Allan

  • lbermudezlbermudez Posts: 5Questions: 0Answers: 0
    edited August 2

    Edit: I was wrong, it does detect the date format. and works fine with

    'DD/MM/YYYY HH:mm'

    but with my column DD/MM/YYYY fails only with the "equals" condition.
    works fine with before, after, empty, etc...

    And this problem seems to happen too with SearchBuilder, so the main topic on this post, the loop, i think it's fixed.

  • allanallan Posts: 65,856Questions: 1Answers: 10,956 Site admin

    Excellent - one step forward.

    Are you able to give me a link to your page showing the issue with the date search not matching please? I haven encountered that sort of issue before, but another example demonstrating the problem would be very useful.

    Allan

  • lbermudezlbermudez Posts: 5Questions: 0Answers: 0
    edited 1:05PM

    Nevermind, Allan, while preparing a demoIi realized that the problem must be on how php builds the query and since my composer was targeting latest

    "datatables.net/editor-php"

    but i didnt realize the package has changed names to
    "datatables.net/php": "^3.0",

    quick composer update and everything is working as intended

    Thanks so much

  • coreyg142coreyg142 Posts: 20Questions: 1Answers: 0

    Thanks Allan,
    The nightly build seems to fix the loop issue, thanks for getting on that so quickly!

    I'll let you know if I encounter anything else.

  • SirolliSirolli Posts: 3Questions: 1Answers: 0
    edited 6:17PM

    I upgraded to 3.0.1 today and am experiencing this issue. I'm using the columnControl searchDropdown, and it looks like the date columns are still breaking it, causing an infinite loop. I have everything in columnDefs:

    {
                targets: '_all',
                columnControl: {
                    target: 0,
                    content: ['reorder', 'order',
                        // // Original content option that breaks
                        // {
                        //     extend: 'searchDropdown',
                        //     allowSearchList: true,
                        //     search: false,
                        //     select: false,
                        // },
                        // // Replaced the above with this to work around the issue:
                        {
                            extend: 'dropdown',
                            text: 'Search',
                            icon: 'search',
                            content: [{
                                extend: 'searchText',
                                allowSearchList: true,
                                search: false,
                                select: false,
                            }]
                        }]
                },
                className: 'collapsing',
                defaultContent: ''
    },
    
  • SirolliSirolli Posts: 3Questions: 1Answers: 0

    My apologies, I thought I saw a comment saying this was fixed in 3.0.1, I just saw the above comments about the nightly builds. I also tested the nightly builds and it fixes the issue for me too.

  • allanallan Posts: 65,856Questions: 1Answers: 10,956 Site admin

    Awesome - many thanks for the updates everyone. Glad to hear that has fixed that particular issue. I'll tag up and release DT 3.0.2 probably towards the end of next week.

    Allan

Sign In or Register to comment.