Created
February 26, 2015 13:17
-
-
Save Angularjschile/1170ea3ba7d263b584e3 to your computer and use it in GitHub Desktop.
pivotDirective
This file contains 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('pivotDirective') | |
.directive('pivot', ['localStorageService', function (localStorageService) { | |
return { | |
restrict: 'AE', | |
scope: { | |
data: '=' | |
}, | |
link: function (scope, elem, attr) { | |
var renderers = $.extend($.pivotUtilities.renderers ); | |
var conf=localStorageService.get('pivot'); | |
if (conf==null){ | |
conf={roww:[],cols:[]}; | |
} | |
$(elem).pivotUI(scope.data, { | |
renderers: renderers, | |
rendererName: "Table", | |
cols:conf.cols, | |
rows:conf.rows, | |
onRefresh: function (config) { | |
var config_copy = JSON.parse(JSON.stringify(config)); | |
//delete some values which are functions | |
delete config_copy["aggregators"]; | |
delete config_copy["renderers"]; | |
delete config_copy["derivedAttributes"]; | |
//delete some bulky default values | |
delete config_copy["rendererOptions"]; | |
delete config_copy["localeStrings"]; | |
localStorageService.set('pivot',config_copy) | |
scope.$apply(); | |
} | |
}) | |
} | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment