mirror of
https://github.com/nasa/openmct.git
synced 2025-03-21 03:25:44 +00:00
[Table] Export table contents as CSV
This commit is contained in:
parent
f21f22d95c
commit
699f6ba458
@ -12,7 +12,7 @@ define(
|
||||
* @param element
|
||||
* @constructor
|
||||
*/
|
||||
function MCTTableController($scope, $timeout, element) {
|
||||
function MCTTableController($scope, $timeout, element, exportService) {
|
||||
var self = this;
|
||||
|
||||
this.$scope = $scope;
|
||||
@ -47,7 +47,13 @@ define(
|
||||
setDefaults($scope);
|
||||
|
||||
$scope.exportAsCSV = function () {
|
||||
window.alert("Export!");
|
||||
var headers = $scope.headers;
|
||||
exportService.exportCSV($scope.displayRows.map(function (row) {
|
||||
return headers.reduce(function (r, header) {
|
||||
r[header] = row[header].text;
|
||||
return r;
|
||||
}, {});
|
||||
}), { headers: headers });
|
||||
};
|
||||
|
||||
$scope.toggleSort = function (key) {
|
||||
|
@ -81,7 +81,13 @@ define(
|
||||
return {
|
||||
restrict: "E",
|
||||
template: TableTemplate,
|
||||
controller: ['$scope', '$timeout', '$element', MCTTableController],
|
||||
controller: [
|
||||
'$scope',
|
||||
'$timeout',
|
||||
'$element',
|
||||
'exportService',
|
||||
MCTTableController
|
||||
],
|
||||
scope: {
|
||||
headers: "=",
|
||||
rows: "=",
|
||||
|
Loading…
x
Reference in New Issue
Block a user