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

Export without pagination #8

Open
cboden opened this issue May 12, 2014 · 22 comments
Open

Export without pagination #8

cboden opened this issue May 12, 2014 · 22 comments

Comments

@cboden
Copy link

cboden commented May 12, 2014

I'm using ng-table 0.3.1 with ng-table-export master branch. When I export to csv I only get the results of the page and count that has been selected. I would like to download the full result set, not just the current page that is being displayed.

Ideally could the export trigger the ngTableParams.getData function with a parameter indicating it's a csv export. I could then choose to paginate or not.

@andrewboni
Copy link

+1 for this

@fizerkhan
Copy link

+1.

@ansofi
Copy link

ansofi commented Jul 3, 2014

I also +1 one this!

@davisford
Copy link

I believe this is related to esvit/ng-table#114. The pager + group functionality seems broken in ng-table proper; I think if that issue got fixed, this issue would be resolved.

Sorry, not related. I didn't realize that the way he implemented is he is just scraping the table for the values. I concur -- what @cboden said above, using getData is the way to go, and seems like it would be simpler.

@ghost
Copy link

ghost commented Jul 25, 2014

+1 !!!

Thanks!

@brianglick
Copy link

+1

1 similar comment
@elebescond
Copy link

+1

@davisford
Copy link

I had to solve this. I forked the repo, and rebuilt the plugin -- see the README https://github.com/davisford/ng-table-export

Unfortunately, this was a fairly big re-write of the plugin, so I'm not going to send a PR. I've only been testing it in my own project and it seems to work fairly well. I have a lot of different report style pages with charts and many different tables, and it is working so far. Feel free to try it. If you're using bower, you can just point the dependency in bower.json to

"ng-table-export": "https://github.com/davisford/ng-table-export.git"

and try it out. The usage has changed slightly, so consult the updated README. There are a few other improvements listed there as well.

Finally, while using getData() would ultimately seem like the right approach here, I get now why it may not be optimal. My tables have group headers, table headers, footers -- all providing things like summary aggregate values, etc. This stuff doesn't exist in getData()...so for me, parsing the HTML is actually better because the exported csv matches the table format precisely.

caveat -- works in chrome and firefox. in safari, it opens and displays the csv. have not tested IE b/c we are not targeting it.

Cheers.

@TheKojuEffect
Copy link

+1

@abhisheksimion
Copy link

@martinspielmann
Copy link

+1

@davisford
Copy link

@abhisheksimion thanks -- feel free to send back a pr if you have improvements. FWIW, i have been using my solution in production now for about 6 months with zero issues.

I wrote a similar plugin to export XLS format.

@thiagodp
Copy link

This problem can be solved from (at least) two ways:

  1. Passing limit = 0 and offset = 0 to the server, for generating the full list (I consider these values to mean "no limit" and "no offset") and then exporting it;
  2. Configuring the number of items per page equal to a large number (e.g. 999999999). When the user clicks it, the full list is shown and Export will export all the content.
    The second one can be interesting for the user. He/she can export just a limited set of the data or the full data. The same applies to printing.

@davisford
Copy link

hello @thiagodp thanks for the input, and no offense but i think you're a bit late to the party.

solution 1 is a totally different solution unrelated to ng-table-export. this plugin parses the html table in memory and regenerates it as a download link in csv format.

i forked and modified the repo to do something similar to solution 2. i set the # pager rows to Infinity, parse the results into csv, generate the download link and then set it back to whatever the pager was set to before.

we've been hammering on this in production for nearly a year, and we get a lot of csv and xls exports -- it has worked flawlessly for us. caveat: we don't do millions of rows - that gets to just be infeasible inline in the browser and real client/server paging is called for, but it can deal with several thousand rows without the blink of an eye. of course it depends on your hardware, but with modern 2010's hardware it has not been an issue for us.

@thiagodp
Copy link

Hello @davisford, I don't think I'm late to the party: there are people still using esvit's solution. These can still benefit from my suggestion. Glad to hear your solution has been worked well. I think I will try it. Could you also solve the UTF problem? Thanks.

@davisford
Copy link

Which problem with UTF?

@thiagodp
Copy link

#16 (please see my comment)

@zejli
Copy link

zejli commented May 28, 2015

Hello every body,
I forked the new repo and followed the way to use the export CSV like it is shown in the README.My csv show only the current rows in the page.Not all the pages.am I missing something ?

@arseneoaa
Copy link

Hello,
If you also find that the logic printing all rows in the table and not just those displayed (by expanding the pagination) doesn't work, it may be because you are not using "tableParams" as your tableParams variable, @davisford has covered that: try adding it as a 3rd argument like:

a(ng-controller='MyCtrl', ng-click='csv.generate($event, filename() + ".csv", $scope.myCustomTableParams)', href='')

@populationtwo
Copy link

@arseneoaa Adding 3rd argument doesn't seem to work on controller as styntax.

<a ng-controller='MyCtrl as mc' ng-click='csv.generate($event, filename() + ".csv", mc.myCustomTableParams)'></a>

Any clue? Thanks

@antusith
Copy link

antusith commented Jan 2, 2017

Hello, does anybody could explain how to make it work ?
I've written my code like this but nothing is triggered...

https://jsfiddle.net/krptko55/

@saniddha
Copy link

saniddha commented Apr 7, 2017

@davisford

  • define a global variable in ng-table.js like
    var selectedEntries =''";

  • Then inside the getData function in the ng-table.js insert following line
    selectedEntries = orderedData;

function getData(data, params) {
if (data == null){
return [];
}

                var options = angular.extend({}, defaultDataOptions, params.settings().dataOptions);

                var fData = options.applyFilter ? applyFilter(data, params) : data;
                var orderedData = options.applySort ? applySort(fData, params) : fData;
                selectedEntries = orderedData;
                return options.applyPaging ? applyPaging(orderedData, params) : orderedData;
            }
  • Then write a simple function inside the ng-table.js like following
    this.orderedData = function () {
    return selectedEntries
    };

  • Then you can call as following in the controller and get all the filtered entries
    $scope.self.tableParams.orderedData();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests