Closed trpansh closed 10 years ago
Hi, I'm not sure what you mean, what is downloadProjects ? Can you please post an example of the wanted usecase ?
<button type="button" ng-csv="downloadProjects" csv-header="['Field A', 'Field B', 'Field C']" filename="test.csv">Export</button>
downloadProjects is a data to be exported to CSV which is in the format as follows [{ "agency": "Road boards", "budget": 0.0, "category": "GOODS", "contractor": "", "status": "Closed", "title": "DR23-4/070-71 /139" }] and I was wondering whether we could use key as csv-header dynamically.
Sorry for my late response, You can just send a function to csv-header that returns Object.keys(downloadProjects)
I'd also like something like this- where the key of an object becomes the column header. By loading the csv-header
separately with something like Object.keys()
like you mentioned, there is no order guarantee:
// array like object with random key ordering
var an_obj = { 100: 'a', 2: 'b', 7: 'c' };
console.log(Object.keys(an_obj)); // console: ['2', '7', '100']
Can we use header from the data "downloadProjects" on csv-header instead of "['Field A', 'Field B', 'Field C', 'Field D', 'Field E']" and how do we do it?