diff --git a/src/DataCollector/DataTableDataCollector.php b/src/DataCollector/DataTableDataCollector.php index 5c4287a1..d36222d0 100644 --- a/src/DataCollector/DataTableDataCollector.php +++ b/src/DataCollector/DataTableDataCollector.php @@ -16,6 +16,7 @@ use Kreyu\Bundle\DataTableBundle\Filter\FilterInterface; use Kreyu\Bundle\DataTableBundle\Filter\FilterView; use Kreyu\Bundle\DataTableBundle\Filter\FiltrationData; +use Kreyu\Bundle\DataTableBundle\Pagination\PaginationData; use Kreyu\Bundle\DataTableBundle\Sorting\SortingData; use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector; use Symfony\Component\HttpFoundation\Request; @@ -118,6 +119,13 @@ public function collectSortingData(DataTableInterface $dataTable, SortingData $d } } + public function collectPaginationData(DataTableInterface $dataTable, PaginationData $data): void + { + $this->data[$dataTable->getName()]['page'] = $data->getPage(); + $this->data[$dataTable->getName()]['per_page'] = $data->getPerPage(); + $this->data[$dataTable->getName()]['total_count'] = $dataTable->getPagination()->getTotalItemCount(); + } + public function collectFilterView(FilterInterface $filter, FilterView $view): void { $this->data[$filter->getDataTable()->getName()]['filters'][$filter->getName()]['view_vars'] = $this->ksort($view->vars); diff --git a/src/DataCollector/DataTableDataCollectorInterface.php b/src/DataCollector/DataTableDataCollectorInterface.php index f3fa6d35..602964e5 100644 --- a/src/DataCollector/DataTableDataCollectorInterface.php +++ b/src/DataCollector/DataTableDataCollectorInterface.php @@ -14,6 +14,7 @@ use Kreyu\Bundle\DataTableBundle\Filter\FilterInterface; use Kreyu\Bundle\DataTableBundle\Filter\FilterView; use Kreyu\Bundle\DataTableBundle\Filter\FiltrationData; +use Kreyu\Bundle\DataTableBundle\Pagination\PaginationData; use Kreyu\Bundle\DataTableBundle\Sorting\SortingData; use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; use Symfony\Component\VarDumper\Cloner\Data; @@ -30,6 +31,8 @@ public function collectColumnValueView(ColumnInterface $column, ColumnValueView public function collectSortingData(DataTableInterface $dataTable, SortingData $data): void; + public function collectPaginationData(DataTableInterface $dataTable, PaginationData $data): void; + public function collectFilterView(FilterInterface $filter, FilterView $view): void; public function collectFiltrationData(DataTableInterface $dataTable, FiltrationData $data): void; diff --git a/src/DataCollector/DataTableDataExtractor.php b/src/DataCollector/DataTableDataExtractor.php index e8574464..e80a1cef 100644 --- a/src/DataCollector/DataTableDataExtractor.php +++ b/src/DataCollector/DataTableDataExtractor.php @@ -42,9 +42,6 @@ public function extractDataTableConfiguration(DataTableInterface $dataTable): ar 'persistence_enabled' => $dataTable->getConfig()->isPersonalizationPersistenceEnabled(), ], ], - 'page' => $dataTable->getPagination()->getCurrentPageNumber(), - 'per_page' => $dataTable->getPagination()->getItemNumberPerPage(), - 'total_count' => $dataTable->getPagination()->getTotalItemCount(), ]; ksort($data['passed_options']); diff --git a/src/DataTable.php b/src/DataTable.php index d47e957f..b04cfaf1 100755 --- a/src/DataTable.php +++ b/src/DataTable.php @@ -818,6 +818,7 @@ private function dispatch(string $eventName, DataTableEvent $event): void private function resetPagination(): void { $this->pagination = null; + $this->resultSet = null; } private function getInitialPaginationData(): ?PaginationData diff --git a/src/Resources/views/themes/base.html.twig b/src/Resources/views/themes/base.html.twig index 7ad3e988..2bc1d98d 100755 --- a/src/Resources/views/themes/base.html.twig +++ b/src/Resources/views/themes/base.html.twig @@ -205,9 +205,29 @@ {% block pagination_per_page_form %}