The datatable processes only one request
The datatable processes only one request
gabrielfalieri
Posts: 4Questions: 3Answers: 0
Good Afternoon (in Brasil)
So, I'm doing a custom selects system with the datatable, except that the request only processes once.
example of my php, js and html
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>
</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']."%' ";
}
This discussion has been closed.