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

Filtering support for CSV export #982

Closed
DGoms opened this issue Sep 28, 2016 · 9 comments
Closed

Filtering support for CSV export #982

DGoms opened this issue Sep 28, 2016 · 9 comments
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@DGoms
Copy link

DGoms commented Sep 28, 2016

Hello,
I use the filtering of data table and i would like to retrieve the displayed data.
There is a way to retrieve or it was not implement ?
I watched the source code and I did not see any way to do it.

I also noticed that the csv export does not take into account the filtered data, which I find a bit strange.

Thanks

@bomberblue07
Copy link

CSV export applying to filtered data would be a great feature. +1

@cheng1994
Copy link

You could make a change to primeng in node_modules. What happens on exportCSV function is that its using values instead of dataToRender. Technically all the fields of each object are identical at least from what I've seen. Not sure if there is any other diffs between them. Its just that DataToRender will accurately show the filtered items.
So in datatable.js under export CSV change this.values to:

this.dataToRender.forEach(function (record, i) {
            csv += '\n';
            for (var i_1 = 0; i_1 < _this.columns.length; i_1++) {
                if (_this.columns[i_1].field) {
                    csv += _this.resolveFieldData(record, _this.columns[i_1].field);
                    if (i_1 < (_this.columns.length - 1)) {
                        csv += _this.csvSeparator;
                    }
                }
            }
        });

@ajlviv
Copy link

ajlviv commented Apr 7, 2017

Hi guys,

in primeng 2.0.4 it can be fixed easily next way:
...
public exportCSV() {
let data = this.filteredValue || this.value;
...
data.forEach((record, i) => {
...

@tonymedrano
Copy link

tonymedrano commented Apr 19, 2017

@ajlviv, thanks. It works!. How can I get the filtered values to use it later?.

@ajlviv
Copy link

ajlviv commented Apr 19, 2017

You can use onFilter event, something like that:
<p-dataTable #dt [value]="data" (onFilter)="onTableFiltered($event, dt.filteredValue)">

@tonymedrano
Copy link

tonymedrano commented Apr 19, 2017

I do not know how many beers I owe you, @ajlviv.
You've saved my life, thanks!.
working....

@nifrasismail
Copy link

Great! Thanks @ajlviv It works

@oakuraape
Copy link

I concur - thanks @ajlviv . Nice!

@bomberblue07
Copy link

Okay, so if we've figured out how to do it, how come the devs have yet to bin this for release? @ajlviv maybe submit a PR with your changes?

@cagataycivici cagataycivici changed the title Datatable : get filtered values Filtering support for CSV export May 15, 2017
@cagataycivici cagataycivici self-assigned this May 15, 2017
@cagataycivici cagataycivici added the Type: New Feature Issue contains a new feature or new component request label May 15, 2017
@cagataycivici cagataycivici added this to the 4.0.1 milestone May 15, 2017
@cagataycivici cagataycivici added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Type: New Feature Issue contains a new feature or new component request labels May 15, 2017
cagataycivici added a commit that referenced this issue May 15, 2017
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

8 participants