I am displaying a 20k row jquery datatable through django. It is very slow to render. So I am wondering what could be the alternative approaches to process it faster e.g., through defer rendering, to load only the parts that are displayed? The database is in sql.
I tried deferRender and serverSide options to true in datatable options but it is still very slow. I understand that those options work only when the data is called through AJAX. The examples given in datatables website are just dumps of AJAX data into predefined columns. In my case, I am using the data as argument to generate links and create icons etc.
Here is the code:
<div class="container col-9 pb-5 mb-5">
<table id="drugstable" class="table table-hover" style="width: 100%">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Drug</th>
<th scope="col">Tool</th>
<th scope="col">netZoo release</th>
<th scope="col">Network</th>
</tr>
</thead>
<tbody>
{% for drug in drugs %}
<tr>
<th scope="row">{{ forloop.counter }}</th>
<td><a href="{{ drug.drugLink }}">{{ drug.drug }}</a></td>
<td>{{ drug.tool }}</td>
<td>{{ drug.netzoo }} <a href="{{ drug.netzooLink }}">{{ drug.netzooRel }}</a></td>
<td><a href="{{ drug.network }}" download><i class="fas fa-download"></i></a></td>
</tr>
{% endfor %}
</tbody>
</table>
Here is the corresponding JavaScript
<script>
$(function () {
$('[data-toggle="popover"]').popover();
})
// Basic example
$(document).ready(function() {
//datatables
$('#drugstable').DataTable({
"dom": "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
});
} );
</script>