Is possible to create search filter to search from not one field, but from CONCAT(name, description)
?
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper->add('search');
}
The easiest way to filter multiple columns in Excel is to use the Advanced Filter function. The following examples show how to use this function in two different scenarios: Filter for rows that meet multiple conditions. Filter for rows that meet one of multiple conditions.
1. Enter this formula: =ISERROR(MATCH("Helen",A2:C2,0)) into cell D2, and then drag the fill handle down to the cells to apply this formula, and the FALSE and TRUE displayed into the cells, see screenshot: Note: In the above formula: “Helen” is the criteria that you want to filter rows based on, A2:C2 is the row data.
I found solution with doctrine_orm_callback type
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add( 'text', 'doctrine_orm_callback', array(
'callback' => array($this, 'getSearchFilter'),
'field_type' => 'text'
) );
}
public function getSearchFilter($queryBuilder, $alias, $field, $value) {
if (!$value['value']) {
return;
}
$exp = new \Doctrine\ORM\Query\Expr();
$queryBuilder->andWhere($exp->like($exp->concat($alias.'.name', $alias.'.description'), $exp->literal('%' . $value['value'] . '%')));
return true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With