Skip to content
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

Custom Table CSV Export Headers #11120

Closed
fisherstevenk opened this issue Jan 31, 2022 · 0 comments
Closed

Custom Table CSV Export Headers #11120

fisherstevenk opened this issue Jan 31, 2022 · 0 comments
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@fisherstevenk
Copy link

fisherstevenk commented Jan 31, 2022

[ ] bug report => Search github for a similar issue or PR before submitting
[x] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior
Current CSV header row is either the Column 'header' or the Column 'field'
From https://github.com/primefaces/primeng/blob/master/src/app/components/table/table.ts

        for (let i = 0; i < columns.length; i++) {
            let column = columns[i];
            if (column.exportable !== false && column.field) {
                csv += '"' + (column.header || column.field) + '"';

                if (i < (columns.length - 1)) {
                    csv += this.csvSeparator;
                }
            }
        }

Expected behavior
Add "exportHeader" or similar field to Column to allow for a custom CSV header row

Change would be something like the following:

        for (let i = 0; i < columns.length; i++) {
            let column = columns[i];
            if (column.exportable !== false && column.field) {
                csv += '"' + (column.exportHeader || column.header || column.field) + '"';

                if (i < (columns.length - 1)) {
                    csv += this.csvSeparator;
                }
            }
        }

What is the motivation / use case for changing the behavior?
It can make the exported CSV immediately usable for programatically importing data without having to worry about "header to field name" mappings or order of the values. Ultimately will help ease maintainability if the table or underlying data changes.

@yigitfindikli yigitfindikli added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Feb 3, 2022
@yigitfindikli yigitfindikli added this to the 13.1.1 milestone Feb 3, 2022
yigitfindikli added a commit that referenced this issue Feb 9, 2022
Fixed #11120 - Table | Custom Table CSV Export Headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

3 participants