Ah - if you are using server-side processing, then until about two days ago my demo script didn't actually take the bSearchable flag into account for the global filter... An update to the script is available here: http://datatables.net/development/server-side/php_mysql
mmm.... this is my code:
[code]
/*
* Filtering
* NOTE this does not match the built-in DataTables filtering which does it
* word by word on any field. It's possible to do here, but concerned about efficiency
* on very large tables, and MySQL's regex functionality is very limited
*/
$sWhere = "";
if (isset($_GET['sSearch']) && $_GET['sSearch'] != "") {
$sWhere = "WHERE (";
for ($i = 0; $i < count($aColumns); $i++) {
/*
* Qui salto il where sul settimo campo
* (DATE_FORMAT((DATE_ADD(MAX(tbl_progetto.presa_in_carico_data),INTERVAL 12 DAY)),'%d-%M-%Y'))
*
*/
Yeah, around like 11 you need a check on $_GET['bSearchable_' . $i] a bit like what is on line 29 (although without the sSearch_{i} check obviously :-)
Have a look at line 92 in the example I linked to before: http://datatables.net/development/server-side/php_mysql - that is what is missing from the code you pasted before.
Replies
Allan
[code]
/*
* Filtering
* NOTE this does not match the built-in DataTables filtering which does it
* word by word on any field. It's possible to do here, but concerned about efficiency
* on very large tables, and MySQL's regex functionality is very limited
*/
$sWhere = "";
if (isset($_GET['sSearch']) && $_GET['sSearch'] != "") {
$sWhere = "WHERE (";
for ($i = 0; $i < count($aColumns); $i++) {
/*
* Qui salto il where sul settimo campo
* (DATE_FORMAT((DATE_ADD(MAX(tbl_progetto.presa_in_carico_data),INTERVAL 12 DAY)),'%d-%M-%Y'))
*
*/
if($i!=7)
{
$sWhere .= $aColumns[$i] . " LIKE '%" . mysql_escape_string($_GET['sSearch']) . "%' OR ";
}
}
$sWhere = substr_replace($sWhere, "", -3);
$sWhere .= ')';
}
/* Individual column filtering */
for ($i = 0; $i < count($aColumns); $i++) {
if (isset($_GET['bSearchable_' . $i]) && $_GET['bSearchable_' . $i] == "true" && $_GET['sSearch_' . $i] != '') {
if ($sWhere == "") {
$sWhere = "WHERE ";
} else {
$sWhere .= " AND ";
}
$sWhere .= $aColumns[$i] . " LIKE '%" . mysql_escape_string($_GET['sSearch_' . $i]) . "%' ";
}
}
[/code]
Allan
Allan