Jhonny from experience I suggest that the filters part do not do it on the datatables plugin if not separately that is to say create a form of filter fields and make ajax requests, every time you do a search you refresh your datatable:
<form class="historyFilters">
<div class="filters">
<div class="col-sm-12 col-md-2">
<label for="">Sitio:</label>
<select class="sites form-control" name="sites">
<option value="">-- Selecciona -- </option>
</select>
</div>
<div class="col-sm-12 col-md-3">
<label for="">Fecha</label>
<input type="text" name="date" class="datepicker form-control" value="">
</div>
<div class="col-sm-12 col-md-3">
<a href="javascript:void(0);" class="btnBuscar btn btn-primary"> <i class="fa fa-search" aria-hidden="true"></i> Buscar </a>
<a href="javascript:void(0);" class="btnlimpiar btn btn-danger"> <i class="fa fa-trash-o" aria-hidden="true"></i> Limpiar </a>
</div>
<div class="row"></div>
</div>
</form>
Then you have to put your tbl with which you will use the datatables plugin:
<div class="tblWrap">
<table class="table-striped tblHis">
<thead>
<tr>
<th>Id</th>
<th>Nombre</th>
<th>Fecha</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
and finally create the js to make the requests and refresh the datatables plugin:
<script>
function cargaGrid(){
// capturo los datos del formulario de filtros
fecha = $('.datepicker').val();
site = $('.sites').val();
// armado de la cadena de peticion que se envia por post en ajax
cad = '_token='+token+'&fecha='+fecha+'&site='+site;
// variable donde almacenara el html de la tabla
tbl = '';
// si el datatable ya esta instanciado sobre la tabla
// se detruye para que al recibir el nuevo contenido se rearme
$('.tblHis').dataTable().fnDestroy();
//vaciado de la tabla antes de insertar los nuevos resultados
$('.tblHis tbody').empty();
// peticion ajax
$.ajax({
type: "POST",
url: "TU_POST_URL",
data: cad,
success:function(data) {
console.info(data);
$.each(data.data,function(i,d){
tbl += '<tr>';
tbl += '<td>'+d.tRenderHistorialId+'</td>';
tbl += '<td>'+d.tRenderHistorialNombre+'</td>';
tbl += '<td>'+d.tRenderHistorialFecha+'</td>';;
tbl += '<td>';
tbl += '<a href="" class="btn btn-primary btn-xs" target="_blank"><i class="fa fa-download" aria-hidden="true"></i></a>';
tbl += '<a href="javascript:void(0);" class="btn btn-default btn-xs uploadFtp"><i class="fa fa-cloud-upload" aria-hidden="true"></i></a>';
tbl += '<a href="javascript:void(0);" class="btn btn-default btn-xs uploadFtp"><i class="fa fa-cloud-upload" aria-hidden="true"></i></a>';
tbl += '</td>';
tbl += '</tr>';
});
// agragamos los resultados al tbl:
$('.tblHis tbody').append(tbl);
// configuracion de datatable:
$('.tblHis').dataTable({
// ordenamiento por defecto de la segunda col.
"order": [[ 2, "desc" ]],
});
}
});
}
// accion para cuando se presiona el boton de busqueda del formulario:
$(document).on('click','.btnBuscar',function(){
cargaGrid();
});
</script>
Greetings and I hope that my answer is for your reference.