SonataAdminBundle
SonataAdminBundle copied to clipboard
:bug: Fix label & method countResults to display good things with simple pager
Subject
Using SimplePager renders wrong statement on batch actions. For example: selecting 50 elements (on a table containing >1000 elements) the batch action checkbox "all_elements" would result in "all elements (51)".
Now with this PR, the display will change. A second basic query will be used to count the total number of results. Using the example above, this would give: "all elements (1000)".
Closes #8164.
Changelog
### Added
- `SimplePager::getTotalResults()` This method actually calculates the number of lines.
### Changed
- `SimplePager::countResults()` The "countResults" method now returns the true total number of lines ;
- `SimplePager::init()` The "init" method also calculates the total number of lines.
### Deprecated
### Removed
### Fixed
### Security
But doesn't this make the simple pager super slow on huge datasets? I thought the whole reason to use the simple pager is because the count of the normal pager would take too long for certain entities?
But doesn't this make the simple pager super slow on huge datasets? I thought the whole reason to use the simple pager is because the count of the normal pager would take too long for certain entities?
This is exactly the purpose of the SimplePager. You lost every benefit with such implementation.
You're right, I'm going to lean more towards the idea of displaying something like this: "25+". I thought that adding a simple query to get the total number of results would be interesting 😉
https://github.com/sonata-project/SonataAdminBundle/pull/8205 strategy should be preferred