Ability to use IN in column level searches
Is there a way to use IN in column level searches? I don't think this is currently possible due to https://github.com/omines/datatables-bundle/blob/master/src/Adapter/Doctrine/ORM/SearchCriteriaProvider.php#L49 which will turn the right operator into 1,2 if you are using ids to narrow the search instead of (1,2)
My proposed solution was https://github.com/omines/datatables-bundle/pull/150 which had the filter column as callable and the callable is passed QueryBuilder $queryBuilder, $field, $search and then the filter can be added like so
'filter' => function (QueryBuilder $queryBuilder, $field, $search) {
$users = explode(',', str_replace(' ', '', $search));
$queryBuilder
->andWhere($queryBuilder->expr()->in($field, ':users'))
->setParameter('users', $users);
}
What other options are there to add flexible column level search?
You should probably extend SearchCriteriaProvider and use your own type of filter (eg: CriteriaFilter/CallableFilter). Maybe there is other way I was not able to figure out yet.
I see what you mean, that is indeed an unfortunate exception to the general case.
@shades684 what's your take on this?
I still think that a column should know absolutely nothing about processing the filter value it's been given. The query is part of Orm in this case and filtering is part of a search criteria provider.
For now @jkabat's solution is the right one for now.
I think @curry684 still has the open issue #15 which is half of the solution. The other part is being able to extend your queries from the ormadapter with callables
Mmm yes correct, #15 is partially at the core of this. I indeed don't see another 'quick route' to a solution here, it's an interesting yet rare case it would seem (took people long enough to run into this).
Stale issue message