Custom Filtering (specifically greater than) server-side
Custom Filtering (specifically greater than) server-side
I am assuming this is client-side only https://datatables.net/examples/plug-ins/range_filtering.html so I cannot use it.
Another "basic" example using a regular input seems straight forward:
table.columns( [0, 1] ).search( 'Fred' ).draw();
However, how would you do age>20?
table.columns( [3] ).search( 'age>20' ).draw();
This of course above looks silly. But is this possible? Or simply doing a smart search table.
Finally, there is using php/ajax (which is probably the right way". Something like:
$select=mysqli_query($conn, "select * from tbl where price<20");
But the final step would be confusing to redraw...
For example, this code below seems very inefficient because it does not use the server.php file.
$data = array();
foreach($result as $row)
{
$sub_array = array();
$sub_array[] = $row['CustomerName'];
$sub_array[] = $row['Gender'];
$sub_array[] = $row['Address'];
$sub_array[] = $row['City'];
$sub_array[] = $row['PostalCode'];
$sub_array[] = $row['Country'];
$data[] = $sub_array;
}
function count_all_data($connect)
{
$query = "SELECT * FROM tbl_customer";
$statement = $connect->prepare($query);
$statement->execute();
return $statement->rowCount();
}
$output = array(
"draw" => intval($_POST["draw"]),
"recordsTotal" => count_all_data($connect),
"recordsFiltered" => $number_filter_row,
"data" => $data
);
Above Code Source: https://www.webslesson.info/2018/09/add-server-side-datatables-custom-filter-using-php-with-ajax.html
Answers
Lastly, there is https://datatables.net/reference/option/ajax.data (probably the right answer) . But this example seems more towards finding a specific word like searching a first name for Fred. Not finding "math" variables like below $100.