Sylius: [Grid] How to filter grid with join entity.

Created on 8 Jul 2016  路  5Comments  路  Source: Sylius/Sylius

I'm deep looking in Grid/GridBundle but can't find the way to filter by using join.

Feature

Most helpful comment

Well this pull request is quite useless ;/ What if I need some fancy joins to do the filtering? Simple getQueryBuilder() getter in the Sylius\Bundle\GridBundle\Doctrine\ORM\ExpressionBuilder would be sufficient. Now I have to use the dirty reflection hack.

All 5 comments

:+1:

I think because DataSource is thought to be generic (ORM, ODM, PHPCR) it prevents us to access query builder.

Maybe introduce a OrmDataSourceInterface? Currently I'm using a very hackish way (reflection to access queryBuilder private property) to modify query builder!!

Anyway another problem I encounter is that Pagerfanta has problems with counting and forces you to do manual counting, and to do that you need to setHint on query! Which you don't have access to even with queryBuilder.

So more flexibility in Grid DataSource is crucial for more advanced usages. WDYT Sylius :) ?

\cc @pjedrzejewski

You have access to custom query builder - https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/AdminBundle/Resources/config/grids/order.yml#L9. What we are missing is entity filter type, that will use entity form to render the choices, then you can easily filter on joint entity. Should be simple to implement. (and actually implemented in old grids at "grids" branch of this repo)

I agree with @aramalipoor to introduce either OrmDataSourceInterface or OrmExpressionBuilderInterface for accessing to the query builder.

Done!

Well this pull request is quite useless ;/ What if I need some fancy joins to do the filtering? Simple getQueryBuilder() getter in the Sylius\Bundle\GridBundle\Doctrine\ORM\ExpressionBuilder would be sufficient. Now I have to use the dirty reflection hack.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikemix picture mikemix  路  3Comments

hmonglee picture hmonglee  路  3Comments

bnd170 picture bnd170  路  3Comments

mezoni picture mezoni  路  3Comments

loic425 picture loic425  路  3Comments