-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathdemoApp.js
More file actions
38 lines (33 loc) · 1.25 KB
/
demoApp.js
File metadata and controls
38 lines (33 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
angular.module('myApp', ['ui.bootstrap', 'dataGrid', 'pagination'])
.controller('myAppController', ['$scope', 'myAppFactory', '$filter', function ($scope, myAppFactory, $filter) {
$scope.gridOptions = {
data: [],
urlSync: true,
customStyle: "item.total.value>1000 ? '' : 'trBack'"
};
myAppFactory.getData().then(function (responseData) {
$scope.gridOptions.data = responseData.data;
});
$scope.exportToCsv = function (currentData) {
var exportData = [];
currentData.forEach(function (item) {
exportData.push({
'Code': item.code,
'Date Placed': $filter('date')(item.placed, 'shortDate'),
'Status': item.statusDisplay,
'Total': item.total.formattedValue
});
});
JSONToCSVConvertor(exportData, 'Export', true);
}
}])
.factory('myAppFactory', function ($http) {
return {
getData: function () {
return $http({
method: 'GET',
url: 'https://angular-data-grid.github.io/demo/data.json'
});
}
}
});