Search code examples
jquery.net-coredatatables

Check when DataTables finished rendering


I'm rendering a lot of data to a table with razor in .Net Core. I'm using DataTables on the table, and trying to add a spinner/loading text while it's loading/rendering the data in the table.

I've tried the initComplete callback, but that fires earlier (at least what I can see in the browser and console.log, it logs a few seconds before it's complete). So is it possible to somehow check if the DataTable completed the render?


Solution

  • initComplete triggers once datatable is initialised. You can use draw delegate instead.
    Have a look at below example

    var table = $('#tableId').DataTable();
    
    table.on( 'draw', function () {
        // your code here
    });