Using colReorder with destroy()

Using colReorder with destroy()

tvainitvaini Posts: 7Questions: 2Answers: 0

Hi there, it's me again having problems with colReorder()

On the first load, the dynamic table is complete generated, with the colReorder, and this works fine

But then I need to generate another dynamic table with another data, and I need to use the same table ID
I call the DataTable().clear() and when I call DataTable.destroy(), it gives me an error like the one below

"Uncaught TypeError: Cannot read properties of null (reading 'dt')
at ColReorder._fnStateSave (dataTables.colReorder.js:853)"

If I don't call the destroy() method, I can't initialise another dynamic table using the same table ID...

Can someone help me please?

Answers

  • colincolin Posts: 12,939Questions: 0Answers: 2,204

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • tvainitvaini Posts: 7Questions: 2Answers: 0

    Hey colin, thanks for your help

    I uploaded the code using debugger and the link is https://debug.datatables.net/usosem

    Can you please take a look to help me ?

  • colincolin Posts: 12,939Questions: 0Answers: 2,204

    Thanks for the debug, but it's the test case or a link to your page that we need to progress this. This will be a flow issue, how your code is interacting at the various steps, so we need to see those steps in action,

    Colin

  • tvainitvaini Posts: 7Questions: 2Answers: 0

    I dont have a DNS to show you the page :neutral: and I can't figure out how to create the example in the test page (I really dont know hot to make it work)
    I tried all the links in the section "How to provide a test case" and my code does not seems to work

    Is there another way you can help me?

  • kthorngrenkthorngren Posts: 14,169Questions: 25Answers: 3,340

    Here is a simple test case demonstrating the problem. Seems to be an issue with ColReorder and StateSave.
    http://live.datatables.net/saxasewa/1/edit

    Kevin

  • demanicdemanic Posts: 1Questions: 0Answers: 0

    For me using destroy(true) solved the problem but the bug is still there

  • allanallan Posts: 54,909Questions: 1Answers: 8,606 Site admin

    Awesome - thanks for the test case Kevin.

    The issue was fixed with this commit and the nightly carries that fix. Updated example.

    We'll tag up this fix in ColReorder in the near future.

    Regards,
    Allan

  • tvainitvaini Posts: 7Questions: 2Answers: 0

    hey guys, thanks for the reply

    but I solved this using jquery.remove("div") and then creating the

    <

    table> with javascript and applying the .DataTable()

Sign In or Register to comment.