how to load data into my datatable, using ajax, custom filtering.
how to load data into my datatable, using ajax, custom filtering.
Hello guys!
I explain a bit, when I am loading my tablet, the data is loaded directly from the PHP server, the method I use to connect to the database is PDO.
but I have all the data, that is, if there is 1000 data, everything is loaded in the first load, this means that there may be a considerable delay or the server hangs etc.
I have a custom filter so what I want is for the first load to show only the first 20 data (the last recorded).
and that through the custom filter for example:
SELECT * FROM TABLE wher search=searchdt;
EXAMPLE AJAX:
<?php
$item = "cod_persona_respr";
$valor= $_SESSION["id"];
$usuarios2 = ModelUsers::ctrShowUsers($item, $valor);
$item = null;
$valor= null;
$Showsdts = ModelTable::ctrShowTable($item, $valor);
foreach ($Showsdts as $key => $value) {
echo '<tr id="filaM'.($key+1).'" class="fila-white">
<td>'.($key+1).'</td>
<td style="color: #305d86;">'.$value["fecha_registro_mp"].'</td>
<td>'.$value["persona_resp"].'</td>
<td>'.$value["lote_p"].'</td>
<td>'.$value["lote_mp"].'</td>
<td>'.$value["viaje"].'</td>
<td>'.$value["fecha_ingres"].'</td>
<td>'.$value["granj"].'</td>
<td>'.$value["galpon"].'</td>
<td>'.$value["sexo"].'</td>
<td>'.$value["line"].'</td>';
if($usuarios2["tipo_user"]=="ADMIN"){
echo
'<td>
<div class="btn-group" role="group" aria-label="Third group">
<button class="btn btn-warning btnEditItem manito-clic" edititem="'.$value["cod_table"].'" idUsuario="'.$usuarios2["cod_persona_respr"].'" User="'.$usuarios2["user_pr"].'" data-toggle="modal" data-target="#modalEditarTable"><i class="fa fa-pencil"></i></button>
</div>
<div class="btn-group" role="group" aria-label="Third group">
<button class="btn btn-danger btnDeleteItem manito-clic" deleteitem="'.$value["cod_table_mp"].'" lotep="'.$value["lote_piku"].'" viajep="'.$value["viaje"].'"><i class="fa fa-times"></i></button>
</div>
</td>'
;
}
echo '</tr>'
;
Necesito convertir un arreglo al formato adecuado y pintarlo sobre la mesa.
cada vez que se aplica el filtro.
So here I need to paint this new data, and in case I clean the custom filter, it returns the data that was initially loaded.
I would appreciate the help, the truth is that this is killing my head.
I speak Spanish, I hope I have made myself understood, thank you.
Replies
The easiest way to do this is to buy an Editor license. That's how I did it a couple of years ago. I didn't want to worry about doing all the CRUD operations myself. Amortization period was less than one working day.
A single developer license is just GBP85 which is just 94 Euros or $110.
Editor is using PDO as well.
https://editor.datatables.net/purchase/index?currency=gbp