Datatable not working when I am using settimeout function?

Datatable not working when I am using settimeout function?

adityaswadityasw Posts: 3Questions: 1Answers: 0

Features like search, sort, pagination, mobile responsive not working. I'm using bootstrap 3, jquery datatable version - 1.10.10

setTimeout(function(){ document.getElementById('tbl_display').reload(innerHTML='
Product NameASINImageReimburseTotal UnitsTotal SalesProfit
SW20 16GB memoryB0245448898image----$30.00$13.00
Scinex Bluetooth headsetB0000089451image----$7.00$3.00
SW30B0245448898imageRefund--$39.00$0.00
'); },3000);

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,703Questions: 26Answers: 4,843

    My guess is you are updating the HTML table without using Datatables APIs so its not updating its data cache which is what searching, sorting, etc use. Its not clear to me exactly what you are doing but you probably will need to use one of the Datatables invalidate methods like rows().invalidate().

    Kevin

  • adityaswadityasw Posts: 3Questions: 1Answers: 0

    Thanks for you response Kevin. But, I have still not got the solution. Maybe that I explained it completely. Please refer to this page - https://www.scinex.com/cnp/dashboard.html
    and table view.
    https://datatables.net/forums/uploads/editor/19/2z1we282i4tx.png

    I am using datables for the first time. and my idea is to bring table's data by ajax that's why 3 second delay in javascipt. Please help

  • colincolin Posts: 15,215Questions: 1Answers: 2,592
    Answer ✓

    Hi @adityasw ,

    The table isn't being initialised - I did it, as in this screen shots, and all good. You just need to do that in your code.

    Cheers,

    Colin

  • adityaswadityasw Posts: 3Questions: 1Answers: 0
    edited March 2019

    Thanks Colin! It worked!!!!
    adding following lines worked -

    setTimeout(function(){
    $('#data-table').DataTable( {
    responsive: true
    } );
    }, 5000);

This discussion has been closed.