Type to search columns, filters, options, and extensions.

↑↓ to navigate · Enter to open · Esc to close

Documentation

Installation

How to install and configure UX DataTables

Requirements

Install the Bundle

    Install via Composer

    composer require pentiminax/ux-datatables

    Symfony Flex will automatically enable the bundle.

    Install Assets

    AssetMapper

    If you’re using AssetMapper (recommended for Symfony 7+), no extra work is needed. The bundle ships DataTables assets automatically.

    Webpack Encore

    If you’re using Webpack Encore, install the JavaScript dependencies and rebuild your assets:

    npm install --force
    npm run watch

    Register the packages you use (recommended)

    php bin/console ux-datatables:install --style=tailwind buttons responsive select

    The command registers only the DataTables packages your tables need, enables the datatable_core controller, and sets package_loading: registered. See Loading only the extensions you use. Skip this step to keep the 1.x behavior, where the datatable controller bundles every package.

    Verify Installation

    The @pentiminax/ux-datatables/datatable Stimulus controller is available in your application, or @pentiminax/ux-datatables/datatable_core if you ran the install command.

Bundle Configuration

Create a configuration file at config/packages/data_tables.yaml:

data_tables:
  options:
    language: en-GB
    layout:
      topStart: pageLength
      topEnd: search
      bottomStart: info
      bottomEnd: paging
    lengthMenu: [10, 25, 50]
    pageLength: 10
  package_loading: registered
  table_attributes:
    class: 'table'
  extensions:
    buttons: [csv, excel, pdf, print]
    select:
      style: single

Configuration Options

OptionDescription
package_loadingregistered loads only the packages you register (see the install command). Leaving it unset is deprecated: the default becomes registered in 2.0
languageDefault language locale (e.g., en-GB, fr-FR)
layoutUI component positions (topStart, topEnd, bottomStart, bottomEnd)
lengthMenuAvailable page length options
pageLengthInitial rows per page
table_attributesDefault attributes for the <table> element
extensionsDefault extensions to enable

Styling

The bundle ships with the DataTables default theme enabled. Check your assets/controllers.json:

{
  "controllers": {
    "@pentiminax/ux-datatables": {
      "datatable": {
        "enabled": true,
        "autoimport": {
          "datatables.net-dt/css/dataTables.dataTables.min.css": true,
          "datatables.net-bs5/css/dataTables.bootstrap5.min.css": false
        }
      }
    }
  }
}

The bundle supports 4 CSS frameworks (Bootstrap 5, Bootstrap 4, Bootstrap 3, and the default DataTables theme). Bootstrap 3 and 4 are deprecated since 1.5 and removed in 2.0. The Stimulus controller automatically detects which stylesheet is loaded and applies the matching integration.

See Styling for the full setup guide.

Optional Dependencies

PackageFeature
symfony/formInline edit modal with auto-generated forms
symfony/twig-bundleRequired for rendering edit modal templates
api-platform/coreAuto-detect columns from API Platform metadata
symfony/mercure-bundleReal-time table updates via Mercure SSE
symfony/maker-bundleThe make:datatable console command