I'm working with datatables and php, so server side .
I've been making custom filters with it, everything working ok, with a save exception, words that have accent, does not work in the filter.
Let's say, I select the following company:
Gabriela and Ana informatics LTDA, it will say that the table is empty.
Not understanding the error, I noticed that this only happened with words that had accentuation, so I looked at the return.
Clearly,theproblemwasclear,butIdonotknowhowtosolveit.
//codethatreturnsjson
$data=array();while($row=mysql_fetch_array($rResult)){//preparinganarray$nestedData=array();$nestedData[]=utf8_encode($row["razao_social"]);
$nestedData[] = utf8_encode($row["organization_name"]);
$nestedData[] = $row["organization_type"];
$nestedData[] = $row["edition"];
$nestedData[] = $row["licensed_version"];
$nestedData[] = date("d/m/Y",strtotime($row["issued_date"]));
$nestedData[] = date("d/m/Y",strtotime($row["support_expiry_date"]));
$nestedData[] = date("d/m/Y",strtotime($row["updates_expiry_date"]));
$nestedData[] = $row["advanced_clients_licensed"];
$nestedData[] = $row["users_licensed"];
$nestedData[] = "<a href='detail-license.php?id=".$row['id_license']."'><button class='btn btn-success'><i class='fa fa-list'></i> Detalhes</button></a>";
$nestedData[] = "<a href='download.php?id=".$row['id_license']."'><button class='btn btn-success'><i class='fa fa-download'></i> Download</button></a>";
$data[] = $nestedData;
}
$output = array(
"draw" => intval($_GET['draw']),
"recordsTotal" => $iTotal,
"recordsFiltered" => $iFilteredTotal,
"data" => $data
);
echo json_encode( $output );
// code that sends to php to do data processing
$('#btnFiltrar').on( 'click', function () {
var dados = new Array();
$('#frmReportLicense').find(":text:visible,:checkbox:checked,select:visible,input:checked").each(function(v) {
dados[v] = $(this).val();
});
dataTable.columns().search(dados).draw();
console.log(dados);
});
Update
In my output I put:
$output = array(
"draw" => intval($_GET['draw']),
"recordsTotal" => $iTotal,
"recordsFiltered" => $iFilteredTotal,
"data" => $data
);
echo json_encode( $output, JSON_UNESCAPED_UNICODE );
It even started to return the right value, only it does not filter.