When I query a large amount of data with datatables, no display

When I query a large amount of data with datatables, no display

feng xiafeng xia Posts: 9Questions: 3Answers: 0
edited May 2021 in Free community support

When I query a large amount of data with datatables,no display

 function query_stock() {
    $("#Button_stock").click(function () { 
        $.ajax({
            url: '/querydata',
            type: 'POST',
            data: {
                csrfmiddlewaretoken: $('[name=csrfmiddlewaretoken]').val(),
            },
            success: function (res) {
                console.log(res)
                $("#myTable2").DataTable().clear();
                $("#myTable2").DataTable().rows.add(res.data).draw();
            }
        });
    })
 }

The data is around 7000 items
No problem when querying 300 data items
You can see the returned data from the network in chrome developer mode,console no display

Replies

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    That's an odd way to go. It would be better to use ajax.reload() rather than adding all the rows through the API.

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

  • feng xiafeng xia Posts: 9Questions: 3Answers: 0

    Thank you very much, but your method doesn't work.
    The main thing is that I can't find the bug, I tried another identical API and had no problem querying 100,000 entries.
    Attached is the initialization function

    function table_stock_initialization(){
        var dataset_2 =[['0','0','0','0','0','0','0','0']];
        $('#myTable2').DataTable({
            data: dataset_2,
            buttons: ['excel',],
            "dom": '<"col-12 col-sm-2"l><"col-12 col-sm-2"B><"col-12 col-sm-2"f><"col-12 col-sm-6"p>t<"bottom"i><"clear">',
            "order": [[ 5, "desc" ]],
            'iDisplayLength':25,
        });
    }
    
  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    Colin asked for a test case
    https://datatables.net/manual/tech-notes/10
    in accordance with the forum rules.
    Otherwise you have not supplied sufficient detail.

This discussion has been closed.