Filter rendered column with server side processing
Filter rendered column with server side processing

Hi,
I've tried to filter data that are rendered. To make it easy I've summarized the code:
var columnas = [
{"data": 'maquina_id', name:'maquina_id', searchable: true },
];
var columnDefs = [{
"targets": 4, //maquina
"render": function(data, type, row) {
return '<a href="'+baseUrl+'/maquinas/'+data+'">\
Nº de serie: '+row['numero_serie']+' <br>\
Marca: '+row['maquina_marca']+' <br>\
Modelo: '+row['maquina_modelo']+'\
</a>';
}
}];
$('#lista').DataTable( {
"processing": true,
"serverSide": true,
"search": {
"caseInsensitive": true
},
"ajax": baseUrl+"/datatable",
"columns": columnas,
"columnDefs" : columnDefs,
"searching": true
});
On server I have something like this:
[...]
$q = $a->datatable();
return Datatables::of( $q->get() )->setTransformer('App\Transformers\AlbaranTransformer')->make(true);
[...]
Well, If I search something, datatable does not filter by "numero_serie", "maquina_marca" or "maquina_modelo".
Wich is the appropiate way to do this?
Thank you
This discussion has been closed.
Answers
Since you are using "serverSide": true, you need to do the search/filtering in your backend or database and return the results.
Hi Dalex,
Yes you are right in part, but if I use serverSide with DataTable plugin, the plugin makes a query like:
And when I add more "where", It looks like:
This behaviour is not the right way