DatatablesBundle icon indicating copy to clipboard operation
DatatablesBundle copied to clipboard

[Extensions Buttons] Allow using a template for body format when exporting

Open tanasecosminromeo opened this issue 6 years ago • 2 comments

I've started this pull request as the datatime was rendered incorrectly (moment javascript was displayed when exporting a datatime field rather than the actual information). This may have been fixable in another way, but having the option to use a template for the function of the body is valuable.

Example of how to use.

Datatable.php $this->extensions->set(array( 'buttons' => array( 'show_buttons' => array('copy', 'print', 'excel'), // built-in buttons array( 'extend' => 'pdf', 'text' => 'my pdf', 'button_options' => array( 'exportOptions' => array( 'format' => array( 'body' => array( 'template' => '@App/Admin/user-format.partial.twig', ), ), ), ), ), ), )));

App/Admin/user-format.partial.twig function ( data, row, column, node ) { if (column === 3){ var date = eval(data.substring(data.lastIndexOf("html(")+5,data.lastIndexOf("))")+1)); return date === undefined ? '' : date; } return $(data).text(); }

tanasecosminromeo avatar Mar 12 '18 15:03 tanasecosminromeo

@stwe Have you managed to have a look?

tanasecosminromeo avatar Aug 29 '18 15:08 tanasecosminromeo

This is useful, ping @stwe

mshd avatar Feb 26 '20 12:02 mshd