datatables-bundle
datatables-bundle copied to clipboard
$value from $request->request->get can be passed before $datatableFactory
my code is
$eventId = $request->request->get('eventId');
$table = $dataTableFactory->create()
->add('firstname', TextColumn::class, ['label' => 'Name'])
->add('lastname', TextColumn::class, ['label' => 'Capacity'])
->add('id', TextColumn::class, [
'render' => function ($value, $context) {
return sprintf('<a href="/admin/manageEvent/edit/%u" class="btn btn-success">Edit</a><a data-id="%u" data-toggle="modal" class="removeEvent btn btn-danger" data-target="#removeEvent">Delete</a>',
$value, $value);
},
'label' => 'Options',
])
->createAdapter(ORMAdapter::class, [
'entity' => User::class,
'query' => function (QueryBuilder $builder) use ($eventId) {
$builder
->select('u')
->from(User::class, 'u')
->where('u.id = :id')
->setParameter('id',$eventId);
}
])
->handleRequest($request);
if ($table->isCallback()) {
return $table->getResponse();
}
$event = $this->em->getRepository(Event::class)->find($eventId);
$eventId can be used in $event = $this->em->getRepository(Event::class)->find($eventId)
and result is returned
but inside anonymous function it's not passed,
if i add $eventId = 2; before $table = $dataTableFactory->create()
, it work just fine
but variable from $request->request->get(
can't be used
i can't understand why? and is there an alternative?
Did you ever fix this?
Doesn't seem like it has anything to do with the bundle, must be something at PHP level or a far fetched issue with http-foundation
, but it's definitely interesting.
i believe this is because of using GET request and query parameters, author probably did not mention the internal datatable POST request that is being invoked is not using these query parameters. I have same issue.
basic url: http://localhost:8081/user-management/ 1] there is form on a page for main filtering (to display users from group 1, 2, ..) - with every change of this form, page is refreshed by GET, e.g. when i select group 3, page is refreshed and url is http://localhost:8081/user-management/?x=3 2] below this form is DataTable which has a context of the form above - I need this table shows only users from selected group - this means I need the internal datatable POST request to be http://localhost:8081/user-management/?x=3 instead of http://localhost:8081/user-management/
is there any way to do this? This question has been raised multiple times here but never answered.
Thx
is there any way to do this? This question has been raised multiple times here but never answered.
I have same issue, anybody found an answer?
Stale issue message