Refresh datatable without using ajax

Refresh datatable without using ajax

VirtualJVirtualJ Posts: 2Questions: 2Answers: 0

Hi all

I'm trying without great success to refresh the content of a datatable without using ajax - using a button.
Data itself is being presented from an SQL query directly on the page.

When the pages opens, data appears as expected.
But when I change the data within the db, then click the reload button, the onClick event (below) does fire, and the table is cleared successfully, but then the table isn't refreshed/reloaded/redrawn at all - remains empty/cleared.

$('#btn-reload').on('click', function(){
         table
         .clear()
         .draw()
    });

Any ideas would be massively appreciated. Many thanks in advance.

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    The problem is Datatalbes is not configured to retrieve the data. You will probably need to reload the data using your direct SQL injection. Maybe this order will work:

    1. Use destroy() to destroy the Datatable
    2. Clear the table
    3. Reload using the direct SQL injection
    4. Reinitialize the Datatable

    This might need adjusting depending on exactly what you are doing.

    Kevin

This discussion has been closed.