1. Go to this page and download the library: Download jul6art/datatable-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jul6art / datatable-bundle example snippets
// config/bundles.php — Flex does this for you
Jul6Art\DatatableBundle\DatatableBundle::class => ['all' => true],
#[Route('/admin/users/export', name: 'admin_user_export')]
public function export(Request $request, DatatableViewExporter $exporter): StreamedResponse
{
return $exporter->stream(
new UserDataTableConfigProvider($this->translator),
'admin_user',
$this->getUser(),
$request,
new CsvWriter(CsvDialect::excelFr()),
'users',
);
}
final class UserDataTableConfigProvider extends AbstractDataTableConfigProvider
{
public function rootEntity(): ?string
{
return User::class;
}
// getColumns(), getFilters() — unchanged
}
public function rootEntity(): ?string
{
return Project::class;
}
public function rowReorder(): ?RowReorder
{
// the key in the URL, the integer position field, the permission that guards the write
return new RowReorder('projects', 'position', 'project:reorder');
}
// the displayed key, by default
$this->apiFilter('site', 'site', 'asset.filter.site', '/api/sites', searchKey: 'search');
// another key — the label is computed, the sort runs on a real column
$this->apiFilter('asset', 'asset', 'defect.filter.asset', '/api/assets', textKey: 'label', orderKey: 'serialNumber');
// no order: the server's order IS the meaning (a rank, a priority)
$this->apiFilter('level', 'level', 'x.filter.level', '/api/levels', orderKey: 'none');
yaml
# translations/javascript.<locale>.yaml
datatable:
dt:
processing: 'Traitement…'
search: 'Rechercher :'
length_menu: 'Afficher _MENU_ éléments'
info: 'Affichage de _START_ à _END_ sur _TOTAL_ éléments'
info_empty: 'Affichage de 0 à 0 sur 0 élément'
info_filtered: '(filtré de _MAX_ éléments au total)'
loading: 'Chargement…'
zero_records: 'Aucun élément trouvé'
empty_table: 'Aucune donnée disponible'
aria:
sort_ascending: ': activer pour trier la colonne par ordre croissant'
sort_descending: ': activer pour trier la colonne par ordre décroissant'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.