I created a Collection Item link but the route is set only on the server side to generates a csv string of my collection and stream it back as a text/csv file. When I click that link I get the csv file downloaded but all my collections documents seem to disappear. If I refresh the page, the documents are back.
I created a Collection Item link but the route is set only on the server side to generates a csv string of my collection and stream it back as a text/csv file. When I click that link I get the csv file downloaded but all my collections documents seem to disappear. If I refresh the page, the documents are back.
AdminDashboard.addCollectionItem(function (collection, path) { if (collection === 'Practitioners') { return { title: 'Export to csv', url: path + '/csv' }; } });
And the route:
Router.route('/admin/Practitioners/csv', {where: 'server'}) .get(function () { var fileData = 'my csv string'; var headers = { 'Content-type': 'text/csv; charset=utf-8', 'Content-Disposition': "attachment; filename=practitioners.csv" }; this.response.writeHead(200, headers); return this.response.end(fileData); this.next(); });