I installed datatables in a page of octobercms. But the data is too large so the rendering of datatables is too slow. Datatables suggests that I should use server-side processing, but I don't know how to.
In octobercms, the data is passed through the builderlist.
{% set records = builderList.records %}
Then, I have the html codes to make the table.
<table id="datalist" class="table table-striped mb-3" style="width:100%;">
<thead>
<tr>
<th>app Id</th>
<th>app Name</th>
<th>app Ver.</th>
<th>BV</th>
<th>Process</th>
<th>SCRIPT</th>
<th>Custom</th>
<th>OS</th>
<th>Period</th>
</tr>
</thead>
<tbody>
{% for record in records %}
<tr>
<td>{{ record.app_id }}</td>
<td>
{% if detailsPage %}
<a href="{{ detailsPage|page({ (detailsUrlParameter): attribute(record, detailsKeyColumn) }) }}">
{% endif %}
{{ attribute(record, displayColumn) }}
{% if detailsPage %}
</a>
{% endif %}
</td>
<td>{{ record.app_ver }}</td>
<td>{{ record.byapps_ver }}</td>
<td>{{ record.app_process }}</td>
<td>{{ record.app_build }}</td>
<td>{{ record.app_os_type == 'both' ? 'and+ios' : record.app_os_type }}</td>
<td>{{ func.dateFormat(record.reg_time) }}</td>
</tr>
{% else %}
<li class="no-data">{{ noRecordsMessage }}</li>
{% endfor %}
</tbody>
</table>
Then here comes the datatable script.
<script type="text/javascript">
$(document).ready(function() {
var tableId = {{ tableName|json_encode()|raw }};
var table = $('#' + tableId).DataTable({
"paging": true,
"pageLength": 50,
"info": false,
"autoWidth": true,
"fixedHeader": false,
"responsive": true,
"orderClasses": false,
"dom": 'Bfrtip',
"buttons": [
'excel', 'copy'
],
});
How can I change these codes to server-side way? Where do I use the ajax? Please, help me !_!