Replies: 2 comments
-
Hey. As you've noticed, the use Kreyu\Bundle\DataTableBundle\Bridge\Doctrine\Orm\Filter\Type\StringFilterType;
$builder
->addFilter('contactPerson', StringFilterType::class, [
'query_path' => 'contactPerson.surname',
])
; This will also fail with "Error: 'contactPerson' is not defined." if you don't add $this->createQueryBuilder('ticket')
->addSelect('contactPerson')
->leftJoin('ticket.contactPerson', 'contactPerson')
// ...
; If you used a different alias, for example This is because the filter adds a WHERE clause to the query like so: Also, please note that the Hope that helps. |
Beta Was this translation helpful? Give feedback.
-
Works as expected <3. Example in controller for future symonfy devs :) SiteController.php #[Route('/path/to/get/ticket/table', name: 'get_ticket_datatable', methods: ['GET'])]
public function get_ticket_datatable(Request $request, TicketRepository $ticketRepository): Response
{
$qb = $ticketRepository->createQueryBuilder('ticket')
->addSelect('contactPerson')
->leftJoin('ticket.contactPerson', 'contactPerson');
$dt = $this->createDataTable(DataTableTicketType::class,$qb);
$dt->handleRequest($request);
return new Response($this->renderView('/dataTable/_dataTable.html.twig', [
'dt' => $dt->createView(),
'target' => 'ticketTable'
]),
200 ,
['Content-Type' => 'text/vnd.turbo-stream.html']);
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Is it possible to filter table by Entity's field with text instead of using ChoiceType?
Primary goal is performance. I'd like to simply use EntityFilterType but with
'form_type' => TextType::class
instead ofChoiceType::class
because I have 10,000+ entities and it takes some time to grab it from the server everytime I load table.I tried to use:
'query_path' => 'contactPerson'
- filter only works when I put ID of the contactPerson'query_path' => 'contactPerson.surname'
- it says Error: 'contactPerson' is not defined.My filter is set to entity (ContactPerson)
Beta Was this translation helpful? Give feedback.
All reactions