Fixed pagination and sorting of tables on pages with ajax
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | 2925598-37.patch | 3.36 KB | saidatom |
| #36 | 2925598-after-patch-35.png | 119.75 KB | djsagar |
| #35 | 2925598-35.patch | 3.34 KB | nileema.jadhav |
| #33 | 2925598-33.patch | 3.21 KB | nileema.jadhav |
| #31 | 2925598-31.patch | 3.36 KB | nileema.jadhav |
Issue fork drupal-2925598
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
shtelya commentedComment #3
shtelya commentedComment #4
shtelya commentedComment #5
shtelya commentedComment #6
fabianx commentedComment #7
vimalabhi89 commentedI'm having the same trouble. I'm returning a tableselect with pager using an ajax callback and the pager urls inlcude
"ajax_form=1&_wrapper_format=drupal_ajax"
Applied this patch which removed '_wrapper_format' from the url of the pagination links, but still inlcuding the ajax_form piece which throws "BrokenPostRequestException"
https://drupal.stackexchange.com/questions/263557/is-there-a-way-to-add-...
Is there any work around for this? I need to filter the data (1000's of records) to return a table with pager within the same page allowing the users to sort the table or paginate
Comment #8
kalistos commentedFix ajax pager on Drupal 8.5
Comment #9
andypostComment #10
rlmumfordUpdated so patch applied on 8.7.x
Comment #11
andypostComment #12
joegl commentedPatch seems to work for pagers, but no code for table sorting and the table sort header links are still broken by AJAX. Maybe I am misinterpreting this issue?
Patch applies cleanly to 8.7 -- updating issue to match.
Comment #13
joegl commentedI am also not sure if the patch is the correct way of writing the query for the pager links, or if it's only necessary because the links are automatically being written incorrectly due to #2504709: Prevent _wrapper_format and ajax_form parameters from bleeding through to generated URLs
However, I do know that to get our pagers to work we've been adding the following to the render array for the pager, to manually strip out the _wrapper_format query parameter:
The patch in this issues fixes the issue so we don't have to manually strip out these paramaters.
Comment #14
joegl commentedFor tablesorting core/includes/tablesort.inc line 63 is:
This seems to run into the same issue as #2504115: AJAX forms should submit to $form['#action'] instead of <current> where the URL is always assumed to be the "current" route. However, when I am rebuilding the table in an AJAX request which say, performs an action on data in a row, the tablesort URL is then written using the URL/route for the AJAX request ("current") instead of the actual page.
Comment #16
andrewbelcher commentedTo fix table sort, we need to do the same thing in
/**\Drupal\Core\Utility\TableSort::getQueryParameters:* Composes a URL query parameter array for table sorting links.
*
* @param \Symfony\Component\HttpFoundation\Request|null $request
* A current request.
*
* @return array
* A URL query parameter array that consists of all components of the
* current page request except for those pertaining to table sorting.
*
* @internal
*/
public static function getQueryParameters(Request $request) {
return UrlHelper::filterQueryParameters($request->query->all(), ['sort', 'order']);
}
?>
I suppose the alternative and more generic solution would be to always filter the AJAX query parameters as part of
\Drupal\Component\Utility\UrlHelper::filterQueryParameters, then anything that performs query parameter filters will have them removed. Or we could do it as part of URL generation, always removing those parameters if they are set. Not sure what the consequences elsewhere of either of those would be - there may be some places that would want to keep them perhaps?Comment #17
kpv commentedChanged patch from #10 to apply to Drupal 8.8.x version.
Comment #19
marceldeb commentedI've tested path #17. It makes a small difference as i stay on the current page (before the patch i navigated to a blank page with a textfield containing the response).
However, it's not working as expected yet.
In my scenario: I use a Drupal.ajax() request to open a view-page in another page. Pager buttons not working in this scenario.
Comment #22
hmdnawaz commentedI am displaying some results from an API on my Drupal page. I used the Drupal core pagination to paginate the results.
When the page loads, the pagination works fine. But when the results are loaded through ajax, the pagination did not work.
I applied patch #17 and it solves my issue. Now my pagination also work when the results are loaded through ajax.
My Drupal version is 9.3.6
Comment #23
kevin.brocatus commentedLike #16 suggested, I added the same fix for \Drupal\Core\Utility\TableSort::getQueryParameters.
Comment #24
kevin.brocatus commentedFixed an issue in the previous patch.
Comment #29
casey commented#24 does not apply to D10
Comment #30
casey commentedComment #31
nileema.jadhav commentedRerolling patch from https://www.drupal.org/project/drupal/issues/2925598#comment-15273232
Comment #32
sarathkmUpdating the version to 10.1 dev
Comment #33
nileema.jadhav commentedAdding/updating patch for 10.0.x
Comment #34
djsagar commentedUpdating the version to 11.x-dev
Comment #35
nileema.jadhav commentedComment #36
djsagar commentedHi @nileema.jadhav,
not able to apply the patch #35 in drupal 11.
for reference

Thanks!
Comment #37
saidatomComment #38
casey commentedIt looks like this issue has been fixed in #3399951: ajax_page_state leaks through request in Views Ajax
Comment #41
s_leu commentedRe #38 : I don't think that issue solved the problem with the pager here and it's neither addressing the issue of sorting which is addressed here.
Comment #42
s_leu commentedComment #43
smustgrave commentedMR appears to have a failure
Comment #44
johnv