3
So I’m making a system of custom selects with the datatable, only the request only processes once.
Example of my php, js and html
<div class="input-group has-feedback" id="divCidade">
<div class="input-group-addon">
<i class="fa fa-envelope"></i>
</div>
<input type="text" class="form-control input-group txtCidade" name="txtCidade" placeholder="Ex.: Belo Horizonte" id="txtCidade" autocomplete="off" maxlength="50" data-columns="10">
</div>
JS
$("#btnFiltro").on('click',function() {
if($(".chkCartaCancelada").is(':checked')) {
var i =$(this).attr('data-columns');//pega o valor da coluna definida para ele
var v =$('.chkCartaCancelada').val();//pega o valor do mesmo
dataTable.columns(i).search(v).draw();//faz a pesquisa dentro do datatable
console.log(v);
}
});
$("#btnFiltro").on('click',function() {
if($(".txtCidade").val() != "") {
var i =$('.txtCidade').attr('data-columns');//pega o valor da coluna definida para ele
var v =$('.txtCidade').val();//pega o valor do mesmo
dataTable.columns(i).search(v).draw();//faz a pesquisa dentro do datatable
console.log(v);
}
});
PHP
if(!empty($requestData['columns'][6]['search']['value'])){
$sql.=" AND status_atual LIKE '".$requestData['columns'][5]['search']['value']."%' ";
}
if(!empty($requestData['columns'][10]['search']['value'])){
$sql.=" AND cidade LIKE '".$requestData['columns'][10]['search']['value']."%' ";
}
Post code not images of them
– R.Santos
The code is getting crazy, but I’ll see here
– gabrielfalieri
Okay, you got the code
– gabrielfalieri
If anyone can help
– gabrielfalieri
How are you getting started with datatables? According to the question, I imagine you are making use of server processing, so it is important to know how you initialized the datatables.
– Juven_v