Table Paginator shows double the expected results on the final page
Closed this issue · 4 comments
kris-sum commented
Something's up with the pagination code, I think something in DoctrineOrmResultSetFactory 's getPaginatorItems isn't quite right:
Worked basic example:
// controller
$table = $this->createDataTable(
TestTableType::class,
$repo->getTestQuery(),
);
$table->handleRequest($request);
return $this->render('test.html.twig', [
'table' => $table->createView(),
]);
// repository
public function getTestQuery(): QueryBuilder
{
$qb = $this->createQueryBuilder('entity');
return $qb;
}
// table
class TestTableType extends AbstractDataTableType
{
public function buildDataTable(DataTableBuilderInterface $builder, array $options): void
{
$builder
->setDefaultPaginationData(new PaginationData(
page: 1,
perPage: 10,
))
->addColumn('moduleCode', TextColumnType::class, [
'sort' => true,
]);
}
}
/test?page_test_table=1
Correctly shows number of pages and item count
Penultimate page /test?page_test_table=31
shows correctly too
Kreyu commented
Thanks for the bug report! I noticed this issue in one of my projects yesterday, but had no time to debug it properly. I think you're right, the result set factory seems to be the cause. I'll try to fix it asap when I'm on my work computer tomorrow :)
kris-sum commented
Thanks for the update :) I would've worked on a fix + PR if I had more time to investigate!
Kreyu commented
kris-sum commented
Looks great! Thank you for the speedy response