1. Go to this page and download the library: Download kreyu/data-table-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/ */
kreyu / data-table-bundle example snippets
class ProductDataTableType extends AbstractDataTableType
{
public function buildDataTable(DataTableBuilderInterface $builder, array $options): void
{
$builder
->addColumn('id', NumberColumnType::class)
->addColumn('name', TextColumnType::class)
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefault('translation_domain', 'product');
}
}
class ProductController extends AbstractController
{
use DataTableFactoryAwareTrait;
public function index(Request $request, ProductRepository $repository): Response
{
$queryBuilder = $repository->createDataTableQueryBuilder();
$dataTable = $this->createDataTable(ProductDataTableType::class, $queryBuilder);
$dataTable->handleRequest($request);
if ($dataTable->isExporting()) {
return $this->file($dataTable->export());
}
return $this->render('product/index.html.twig', [
'products' => $dataTable->createView(),
])
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.