omines / datatables-bundle

DataTables bundle for Symfony
https://omines.github.io/datatables-bundle/
MIT License
262 stars 114 forks source link

How to work with ManyToMany case?? #181

Closed chanondb closed 4 years ago

chanondb commented 4 years ago

I can work on case like simple single One to Many relation is all good.

But as we need to do multi-lang like translations(KNP Translations) or one product can be in many Categories (ManyToMany)

/**

Any suggestions on how can I search from this many to many relationships?

Clorr commented 4 years ago

Hi @chanondb ! I encountered the same problem and replied here: https://github.com/omines/datatables-bundle/issues/30#issuecomment-673962858

If this solves your problem, feel free to close this issue (which is not an issue by the way ;-) )

chanondb commented 4 years ago

Hi @chanondb ! I encountered the same problem and replied here: #30 (comment)

If this solves your problem, feel free to close this issue (which is not an issue by the way ;-) )

Okie Thanks, Let me try to check this solution 'simple_total_query' => false , currently using distinct and a bit custom query. But Order column doesn't work properly
`

               'query' => function (QueryBuilder $qr) use($request) {

                $param = $request->query->all();
                $qr->select('distinct p')

                ->addSelect('groupManager')
                ->from(Product::class, 'p')
                ->leftJoin("p.groupManager" ,"groupManager")
                ->andWhere('p.deletedAt IS NULL');
            }

`

curry684 commented 4 years ago

This is a Doctrine/DQL issue, not really for the bundle to fix 😉