I have angular's ui-grid implemented along with infinite scroll enabled. Currently it only fetches 100 rows at a time - when I enable export to csv in the grid options, by default it will export only how many rows are visible. My question, is there a way to export but get all rows of data? Any input/suggestions are appreciated.
1 Answer
I had the same issue back in months and I found this solution :
From the documentation, you can use exporterAllDataFn property in $scope.gridOptions
gridOptions.exporterAllDataFn = function () {
return $http.get('/data/100.json')
}
As far as I unsterstood, this function is called once you clicked on the exporterMenuCsv menu button 'Export all data as csv'
I also found this good tutorial made by PaulL1, major contributor of the ui-grid lib.
Note: I quickly ended up not using this solution: I wanted to add some formatting/filtering/sorting on each columns, so I made my own export function.
Hope it helps
2 Comments
Buccaneer
I have filtering and sorting built in also, do you mind sharing an example of the export function you added? Basically on my dto i have a parameter: isPaged: true - that is calling a different repository method to run paging and only return 100 at a time - so in my new function I'll need to pass the grid dto with isPaged: false so it calls the getAll method which will return the full result set on export
C-Woap
Sharing my code won't be usefull I guess. But here is what I did : - Created a service 'dataExportServices' In which you can find a function where you make your call to retrieve all data and your filtering/sorting/formatting functions. - I created a graphical component that call this export function in the service.