Created
March 31, 2016 18:31
-
-
Save chanakaDe/8ba8085f069b7be8983353df31ec5249 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('data_visualize') | |
| .controller('ViewPersonController', function ($scope, personService, $interval, $q) { | |
| var fakeI18n = function (title) { | |
| var deferred = $q.defer(); | |
| $interval(function () { | |
| deferred.resolve('col: ' + title); | |
| }, 1000, 1); | |
| return deferred.promise; | |
| }; | |
| $scope.gridOptions = {}; | |
| $scope.showMe = function (id, name) { | |
| alert(id + " - " + name); | |
| }; | |
| personService.viewPersons().then(function (data3) { | |
| console.log(data3); | |
| $scope.allPersons = data3.objects; | |
| $scope.gridOptions = { | |
| exporterMenuCsv: true, | |
| enableGridMenu: true, | |
| gridMenuTitleFilter: fakeI18n, | |
| data: data3.objects, | |
| columnDefs: [ | |
| {name: 'id'}, | |
| {name: 'name'}, | |
| {name: 'phone'}, | |
| { | |
| name: 'Options', | |
| cellTemplate: '<button class="btn success" ng-click="grid.appScope.showMe(row.entity.id,row.entity.name)">Edit</button>' | |
| } | |
| ], | |
| gridMenuCustomItems: [ | |
| { | |
| title: 'Rotate Grid', | |
| action: function ($event) { | |
| this.grid.element.toggleClass('rotated'); | |
| }, | |
| order: 210 | |
| } | |
| ], | |
| onRegisterApi: function (gridApi) { | |
| $scope.gridApi = gridApi; | |
| $interval(function () { | |
| gridApi.core.addToGridMenu(gridApi.grid, [{title: 'Dynamic item', order: 100}]); | |
| }, 0, 1); | |
| gridApi.core.on.columnVisibilityChanged($scope, function (changedColumn) { | |
| $scope.columnChanged = {name: changedColumn.colDef.name, visible: changedColumn.colDef.visible}; | |
| }); | |
| } | |
| }; | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment