Row details together with data from Symfony Doctrine

Row details together with data from Symfony Doctrine

D4rkPh0en1xD4rkPh0en1x Posts: 5Questions: 2Answers: 0
edited November 2018 in Free community support

Hi
Is there a way to use data from a mysql database used from Symfony Doctrine with the row details like in this example:
https://datatables.net/examples/api/row_details.html
A normal row with data from doctrine I already have running
(sorry I'm very new in programming so this maybe a stupid question)

For Symfony to get data I use this example:

use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter;

$table = $this->createDataTable()
    ->add('firstName', TextColumn::class)
    ->add('lastName', TextColumn::class)
    ->add('company', TextColumn::class, ['field' => 'company.name'])
    ->createAdapter(ORMAdapter::class, [
        'entity' => Employee::class,
    ]);

so the table is generated in the controller and than send to the twig template to display.

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Hi @D4rkPh0en1x ,

    It depends what you want in those child rows. As that example shows, the format() function just generates data that gets slotted in as child rows. If you want to pull that data from the server, you'll need some ajax call to retrieve it, if not, you can just generate from the existing row information.

    Hope that helps,

    Cheers,

    Colin

  • D4rkPh0en1xD4rkPh0en1x Posts: 5Questions: 2Answers: 0

    Hi
    so just with Ajax call this is possible?
    as here thanks to Symfony there is a simple connection to the database via ORM/doctrine.

    Within the display template I just use this js entry:

    <script>
    $(function() {
    $('#snlisting').initDataTables({{ datatable_settings(datatable) }})
    });
    </script>

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Hi @D4rkPh0en1x ,

    Yep, if you see this blog post here - it shows how to use Ajax to load data for the child rows.

    Hope that helps,

    Cheers,

    Colin

  • D4rkPh0en1xD4rkPh0en1x Posts: 5Questions: 2Answers: 0

    OK thank you very much :)
    I gonna give it a try

This discussion has been closed.