Good morning guys over stack. I've had a problem for some time, where I can not figure out why.
I'm working with php's datatables, where I make some custom filters. When I select for example, 2 checkbox, and click the button it works perfectly, right after, if I try to change this filter, unchecking this box and selecting another, it does not filter, but sends the request normally.
Follow some of the requisition codes
$("#btnFiltrar").on('click',function() {
if($(".chkTipoEducacional").is(':checked')) {
var i =$('.chkTipoEducacional').attr('data-columns');
var v =$('.chkTipoEducacional').val();
dataTable.columns(i).search(v).draw();
console.log(v);
}
});
$("#btnFiltrar").on('click',function() {
if($(".chkTipoComercial").is(':checked')) {
var i =$('.chkTipoComercial').attr('data-columns');
var v =$('.chkTipoComercial').val();
dataTable.columns(i).search(v).draw();
console.log(v);
}
});
$("#btnFiltrar").on('click',function() {
if($(".chkTipoProfissional").is(':checked')) {
var i =$('.chkTipoProfissional').attr('data-columns');
var v =$('.chkTipoProfissional').val();
dataTable.columns(i).search(v).draw();
console.log(v);
}
});
And some examples of php
if(!empty($requestData['columns'][8]['search']['value']) && !empty($requestData['columns'][11]['search']['value']) && !empty($requestData['columns'][12]['search']['value'])){
$sql .= " AND issued_date BETWEEN '".$requestData['columns'][11]['search']['value']."' AND '".$requestData['columns'][12]['search']['value']."'";
}
if(!empty($requestData['columns'][2]['search']['value'])){
$sql.=" AND licensed_version LIKE '".$requestData['columns'][2]['search']['value']."%' ";
}
Thank you in advance!