Buttons Extension

When To Use

Use Buttons when users need export actions (CSV, Excel, PDF, Print) or column visibility controls.

Minimal Example

use Pentiminax\UX\DataTables\Enum\ButtonType;
use Pentiminax\UX\DataTables\Model\Extensions\ButtonsExtension;

$dataTable->addExtension(new ButtonsExtension([
    ButtonType::COPY,
    ButtonType::CSV,
    ButtonType::EXCEL,
]));

Available Button Types

Button type Purpose
`ButtonType::COPY`Copy table data to clipboard
`ButtonType::CSV`Export CSV file
`ButtonType::EXCEL`Export Excel file
`ButtonType::PDF`Export PDF file
`ButtonType::PRINT`Open print view
`ButtonType::COLUMN_VISIBILITY`Toggle column visibility

Advanced Example

$buttons = (new ButtonsExtension([ButtonType::CSV]))
    ->withExcelButton()
    ->withPrintButton();

$dataTable->addExtension($buttons);

Frequent Pitfalls

  • Mixing button values as invalid strings.
  • Forgetting that non-column-visibility buttons apply export filtering by default.