When using a table display with tablesort as the parent display, the sorts used when click sorting by column aren't applied to the export display. This seems to be because there's a difference between the query parameters from the exposed sorts and tablesorts.

For example:
* sort_by - the exposed sort field name
* sort_order - the exposed sort order (ASC/DESC)
* order - the tablesort field name
* sort - the tablesort order (asc/desc)

Comments

acbramley created an issue. See original summary.

jim22’s picture

I have the same issue. The sort order doesn't carry over from the table column sort results to the data-export (csv). I also am using an exposed pager offset since there is no batch export currently. This actually causes different results in the data-export compared to the results in the page views' table rows.... since the sort doesn't carry over.

yusufhm’s picture

Status: Active » Needs review
StatusFileSize
new1.06 KB

I've added the buildSortPost method to the DataExport style plugin which parses query parameters and adds them to the view's sort.

Status: Needs review » Needs work

The last submitted patch, 3: tablesorts-not-applied-to-export-2893689-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

yusufhm’s picture

Status: Needs work » Needs review
StatusFileSize
new16.5 KB

Uploading new patch with fix.

Status: Needs review » Needs work

The last submitted patch, 5: tablesorts-not-applied-to-export-2893689-5.patch, failed testing. View results

yusufhm’s picture

Status: Needs work » Needs review
StatusFileSize
new1.08 KB

Uploaded the wrong patch; uploading correct one now.

manuel garcia’s picture

StatusFileSize
new1.21 KB
new859 bytes

Thanks for the patch, reworking the logic a bit to make it easier to follow.

jhedstrom’s picture

Status: Needs review » Fixed

Looks good. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jamesyao’s picture

My Drupal site (Drupal Core 9.4.6 and PHP 8.0) runs with the latest version of Views Data Export (8.x-1.1). I have still experienced the issue (Tablesorts not applied to export). After I have tested all scenarios, exporting data does not reflect with the sorting order of the table views.