deferRender not working ?

deferRender not working ?

OradukuyakataterOradukuyakatater Posts: 2Questions: 1Answers: 0

Hi,
I'm having an issue using deferRender as it seems not to work at all. Here's the code:

$.ajax({
url: "main.php",
... // some code
}).fail(function(jqXHR) {
...
}).done(function(data) {
$("#result").html("

" + data + "

");

$("#tab_res tfoot th").each(function() {
    var title = $("#tab_res thead th").eq($(this).index()).text();

    $(this).html("<input type=\"text\" placeholder=\"Search " + title + "\" />");
});

var table = $("#tab_res").DataTable({
    "scrollY": 675,
    "scrollX": true,
    "scrollCollapse": true,
    "lengthMenu": [ 25, 50, 100, 200 ],
    "pageLength": 25,
    "deferRender": true,
    "dom": "Clrtip",
    "createdRow": function( row, data, dataIndex ) {
        console.log("row creation");
     }
});

table.columns().every(function() {
    var column = this;

    $("input", this.footer()).on("keyup change", function() {
        column.search(this.value).draw();
    });
});

}).always(function() {
...
})

main.php is a script that generates the html table. Everything works fine except that console logs shows the number of row in the table. Am I missing something to make deferRender option work ?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Answer ✓

    This appears to be the same as this github issue. The issue is that there is nothing to defer since the DOM elements are already in the HTML - it is an HTML sourced table.

    Allan

  • OradukuyakataterOradukuyakatater Posts: 2Questions: 1Answers: 0

    Yes same post, it works great now (ajax sourced) ! Thanks for your answers.

This discussion has been closed.