Installation
Installation
Install the Bundle
-
Install via Composer
Terminal window composer require pentiminax/ux-datatablesSymfony Flex will automatically enable the bundle.
-
Install Assets
If you’re using AssetMapper (recommended for Symfony 6.4+), no extra work is needed. The bundle ships DataTables assets automatically.
If you’re using Webpack Encore, install the JavaScript dependencies and rebuild your assets:
Terminal window npm install --forcenpm run watch# or with yarnyarn install --forceyarn watch -
Verify Installation
The
@pentiminax/ux-datatables/datatableStimulus controller is now available in your application.
Bundle Configuration
Create a configuration file at config/packages/datatables.yaml:
data_tables: options: language: en-GB layout: topStart: pageLength topEnd: search bottomStart: info bottomEnd: paging lengthMenu: [10, 25, 50] pageLength: 10 template_parameters: class: 'table' extensions: buttons: [csv, excel, pdf, print] select: style: singleConfiguration Options
| Option | Description |
|---|---|
language | Default language locale (e.g., en-GB, fr-FR) |
layout | UI component positions (topStart, topEnd, bottomStart, bottomEnd) |
lengthMenu | Available page length options |
pageLength | Initial rows per page |
template_parameters | Default attributes for the <table> element |
extensions | Default extensions to enable |
Styling
Default Styles
The bundle includes default DataTables styling. Check your assets/controllers.json:
{ "controllers": { "@pentiminax/ux-datatables": { "datatable": { "enabled": true } } }, "autoimport": { "datatables.net-dt/css/dataTables.dataTables.min.css": true }}Using Bootstrap
To use Bootstrap 5 styling instead:
{ "autoimport": { "datatables.net-dt/css/dataTables.dataTables.min.css": false, "datatables.net-bs5/css/dataTables.bootstrap5.min.css": true }}