-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gridfield Better Buttons don't handle sorting and pagination #886
Comments
I am also getting the issue with previous and next button, please find the issue detail below. My Silverstripe version is 4.4 and grid field next and previous button functionality working randomly. I have grid with 25 records. I have two pages in my grid, means item per page is 15 in the grid. When I click on first record on the first page in the grid, I can press next button till the 16th record and then next button is disabled on the 17th record. But when I start from second page in the gird from 18th number record then next record should be the 19th number record but currently after 18th record I am getting 2nd number record as a next record and after that I can see next button till the 16th record and on the 17th record again next button is disabled. In my case I expect next button should work for all the 25 records in the grid and next button should be disabled on the 25th record. But next button disabled after 17th records according to the current code in GridFieldDetailForm_ItemRequest.php at line 540($limit = $itemsPerPage + 2). In second senario, when I click on the 15th number of record on the page 1, I can see next button only for 15th and 16th record and then again next button is disabled on the 17th record, but I think I should be able to see all the record from 15th to 25th (all 10 recods) and next button should be enabled. Same issue with previous button as well, when I click on the 25th number record on page 2, I can see previous button till 16th record and then previous button is disabled on 15th record on page 1. But I expect previous button should work till first record in the grid. Please let me know If you need any other information. |
The pagination will either be incorrect or missing in Ideally we should not depend on the pagination offset and items per page as it's possible to open a record by URL without passing the query string to the detail form. So we'd need to find the index of the current record and then offset from there somehow. |
We think it's worth spending about 3 story points getting the existing PR across the line. If it turns out to be more difficult than that, then we should focus on addressing this issue through https://github.com/silverstripeltd/product-issues/issues/254 |
I've spent some time debugging how the existing implementation works and why selecting the bottom record on the first page of results will only allows you to get 2 more next records. I have not investigated the prev button on the third page of results. I have not investigated records being returned in the wrong order.
Will then re-query the database (I think), respecting sorting and filtering, and get an additional 2 records (15 $itemsPerPage + 2 = 17) with an offset of 0 You can click the next record button 2 times. The issue is that You cannot simply query by record ID, because this doesn't respect sorting or filtering An easy way to solve this would be to re-query the entire database table without a LIMIT or OFFSET, however this is likely to be problematic if you have a gridfield on a database with a 100K records which while it is a lot and you could question if a gridfield is appropriate, CMS users may find handy to do searching/filtering on. It doesn't seems like a good solution just to get a next/prev button. I'm not sure if this is possible, though it seems like solution here would be do another query that includes respect sorting and filtering, and somehow has an OFFSET ( Would this work if you navigated to URL of the item edit form directly without first visiting the gridfield? Given this implementation is currently broken, unless someone is a able to identify a robust solution I'm inclined to remove the next/prev buttons from the edit forms |
@emteknetnz I've just tested this and it looks like the sorting is indeed still broken with the new approach. However, filtering still works:
Not sure how much work would be involved in getting this working properly, but I'll park it for now. |
Closed in favour of #1315 |
Our better button implementation in core seems to have some issues.
https://youtu.be/Mg8sptRZKc8
Parent issue:
Pull request
The text was updated successfully, but these errors were encountered: