Symfony SgDatatablesBundle

I am using SgDatatablesBundle to render a datatable. I am trying use the extension to create a custom button. Even thought I can see the button, when I click on it, I get a javascript message showing that the action function doesn’t exist. This is what I am doing.

$this->extensions->set([
            'buttons' => [
                'show_buttons' => [
                    [
                        'text' => 'New',
                        'action' => array(
                            'template' => 'bundles/SgDatatablesBundle/datatable/new_action.js.twig',
                        ),
                    ],
                ],
            ],
            'responsive' => true,
        ]);

I have this code inside my new_action.js.twig file:

action = function (e, dt, node, config) {
  alert('Activated!');
  this.disable(); // disable the button
}

Every time I click on the button I get this error on the console:
error image

Apparently, for some reason the action function declared on new_action.js.twig is not being found or loaded.

Does anyone have an idea about this issue? I would really appreciate your help as I ran out of ideas on this.

Thanks.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *