Data Table 'flashing' when browser refreshes

Data Table 'flashing' when browser refreshes

CaliweedjobsCaliweedjobs Posts: 10Questions: 3Answers: 0

Hi - I'm new to using datatables.net, I have a datatable on the home page of my site, www.caliweedjobs.com, and it works well, although I recently upgraded to the latest min CDN files, and added a couple arguments in the Javascript and now everytime I'm viewing the data table and refresh it, it flashes quickly, then jumps back to normal. Maybe it's just re-sorting slowly? Please visit the site and see for yourself. Any advice is very much appreciated, thank you.

<script>
$(document).ready( function() {
    $('#datatables0').DataTable({
      "order": [ 4, 'desc' ],
      "pageLength": 20,
      scrollCollapse:true,
      "scrollX": true
    });
});
</script>

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/dt-1.10.18/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.18/datatables.min.js"></script>

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,236Questions: 1Answers: 2,598
    Answer ✓

    Hi @Caliweedjobs ,

    It's probably because the pageLength setting isn't within the supported lengths as defined by lengthMenu. Try setting it to 25 (which is in the default length list), or customise lengthMenu to include 20.

    Cheers,

    Colin

  • CaliweedjobsCaliweedjobs Posts: 10Questions: 3Answers: 0

    thanks @colin, removing pagelength basically doubles the speed, adding lengthmenu undoes some of that benefit, so I'm just not including either for the time being

This discussion has been closed.