omines / datatables-bundle

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

ManyToMany don't dipslay (all tags) in list datatable #287

Closed ArmandArthur closed 1 year ago

ArmandArthur commented 1 year ago

CF down

ArmandArthur commented 1 year ago
        ->add('tags', TextColumn::class, ['label' => 'Tags','field' => 'tag.name','render' => function($value, $context) {
            $str = '';
            foreach ($context->getTags() as $key => $tag) {
                $str .= '<span class="badge badge-phoenix fs--2 badge-phoenix-primary"><span class="badge-label">'.$tag->getName().'</span><span class="ms-1" data-feather="package" style="height:12.8px;width:12.8px;"></span></span>';
            }
            return $str;
        }])
        ->createAdapter(FetchJoinORMAdapter::class, [
            'entity' => Client::class,
            'simple_total_query' => false,
            'query' => function (QueryBuilder $builder) {
                $builder
                    ->select('e')
                    ->addSelect('tag')
                    ->from(Client::class, 'e')
                    ->leftJoin('e.tags', 'tag')

                ;
            },
        ])

I try this code, it's better.

Example: First item have 2 tags (red, blue) and second item have 2 tags too (red, green)

If no search, both items are display with 2 tags.

If i search "red", both items are display but only red tag is display.

It's possible to display all tags when i search "red"?

ArmandArthur commented 1 year ago

Nobody? =P

github-actions[bot] commented 1 year ago

Stale issue message

ArmandArthur commented 1 year ago

Up?

robiinho commented 2 months ago

Hi ArmandArthur,

did you succeed ?