I have a Datatables table with AJAX: https://datatables.net/examples/data_sources/ajax.html Using this class: https://github.com/DataTables/DataTables/blob/master/examples/server_side/scripts/ssp.class.php
This is my Controller:
$whereResult = "";
if(isset($_POST['provider_id'])) {
$whereResult.= "provider = ".$_POST['provider_id']['value'];
}
$table = 'providers_catalog';
$primaryKey = 'id';
$columns = array(
array( 'db' => 'product_id', 'dt' => 0 ),
array( 'db' => 'provider', 'dt' => 1 ),
array( 'db' => 'sku', 'dt' => 2 ),
array( 'db' => 'description', 'dt' => 3 )
);
echo json_encode(
SSP::complex( $_GET, $table, $primaryKey, $columns, $whereResult, $whereAll = null )
);
And in my view I try to make another AJAX call, but it doesn't recharge the table:
$('#provider_id').change(function () {
var txt = {value: $(this).val(), column: "" + $(this).attr('id') + "" };
if(txt != '') {
$.ajax({
url: "Catalog/paginate",
method:"post",
data:{provider_id:txt},
dataType:"text",
success:function(data) {
},error:function () {
alert("Error");
}
});
}
});
The default AJAX Datatables have the input Search that find in any column and then recharge the table, but is integrated with all the components. How can I make custom search fields for each column of my DB?