I am working on a webproject. It is using angularjs on clientside. One of the requirement is to display some data in a grid and give options to export the data into csv file.
I am trying to use ngCsv module for this functionality. I display data in the grid from a collection. While displaying I have control on what columns I can display. But while exporting the data to CSV all that I can use is the collection. When I use the collection it is exporting all the columns from the collection in the exported csv files. But I want to export only specific columns. There may be a way to select only specific columns from the collection in angularjs but I could not find a way to do it.
This is the function that loads apps on the controller
function loadApps()
{
appService.getApps().then(function (result) {
vm.assets = result.data.items;});
}
This function is used to export the apps
vm.exportApps = function () {
return vm.apps.filter(function (a) {
return a.selected;
});
}
This is is from html
<button class="btn btn-sm btn-primary" ng-csv="vm.exportApps" filename="SelectedAppsList.csv">Export Apps </button>
Can somebody suggest as to what I can do to just select specific columns to export ?
You can try to use csv-column-order attribute in your html code.
and specify what columns do you need
they are from your array of objects