Method extractHeaders requires view to have data to generates the header row.

Created on 15 December 2021, almost 3 years ago
Updated 17 November 2023, about 1 year ago

Problem/Motivation

I'm using views_data_export module to export a view result as csv file. Everything works well untill the view we want to export is empty. If there is no result, the csv header row is not generated and the file is empty.

The extractHeaders method seems to priorities results keys over view fields in case of view context. It doesn't seems to be a bug.

Steps to reproduce

  • Install views_data_export which will install csv_serialization 2.0.
  • Create a view page on a content type with exposed filter (pay attention to check the remembering filter option)
  • Add an export data view display and configure it to be csv export and to be shown on the preceding view page
  • Navigate to the view page and add filter which result in an empty table
  • Clic on the export button and open the file

The file is empty with no header row.

Proposed resolution

In case we have a views_style_plugin context, assume that view fields are our header (at least when there is no data).

I'm not sure why this filtering code has been written so I don't know if we can just remove it.

Remaining tasks

Choose either if we keep that filtering feature or not.

✨ Feature request
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡«πŸ‡·France colin.eininger

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024