reload of a HTML DOM Sourced Datatable

reload of a HTML DOM Sourced Datatable

kuddelkuddel Posts: 1Questions: 1Answers: 0

Hello,

I search in the forum, but i could not find any solution for my following problem:

I use to load a Datatable this line

$('#mydiv').load("my_datatable.php");

In my_datatable.php I create the html table fresh from the database!
This work fine so far.

Also each Row has an button to update the current Row. That means over Ajax i update the Database and reload "mydiv" with
$('#mydiv').load("my_datatable.php"); to get the new data.

Now I have a issue which I can not understand:
The record, which i update with the button is now _twice _in the datatable, in the old version and new version. But why? In the database I have only 1 record with the updated data.

Where did the old entry come from?

Can anyone help?

Many thanks
Kuddel

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @kuddel ,

    It's probably because your reloading the table without DataTables knowing about it. After you do the reload, try calling rows().invalidate() to force DataTables to rescan the table.

    If that doesn't work, 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

This discussion has been closed.