Closed paskuale75 closed 4 years ago
applyFilter structure seems to be formed like below:
'applyFilter' => function ($query, $columns, $search) {
//custom search logic
$modelClass = $query->modelClass;
$schema = $modelClass::getTableSchema()->columns;
foreach ($columns as $column) {
$value = empty($search['value']) ? $column['search']['value'] : $search['value'];
if ($column['searchable'] == 'true' && array_key_exists($column['data'], $schema) !== false) {
$query->orFilterWhere(['like', $column['data'], $value]);
}else{
//filter on residenza (extraColumn)
//be careful to use the name of the field you used in the main query->join (not extraColumn name)
$query->orFilterWhere(['like', 'cr.comune', $value]);
}
}
return $query;
},
So, does it work for you now?
extraColumn array in applyOrder works like a charm but not in applyFilter() function, in _array($schema) conditions .. it seems to me that is the cause.