<div class="eg-grid" ng-class="{'eg-grid-as-conf' : showGridConf}">
<!-- import our eg-grid-field defs -->
- <div ng-transclude></div>
+ <div style="display: none;" ng-transclude></div>
<div class="eg-grid-row eg-grid-header-row">
<div class="eg-grid-cell eg-grid-cell-stock" ng-show="showIndex">
<!-- if the cell comes with its own template,
translate that content into HTML and insert it here -->
- <span ng-if="col.template" style="padding-left:5px; padding-right:10px;"
+ <span ng-if="col.template && !col.compiled" style="padding-left:5px; padding-right:10px;"
ng-bind-html="translateCellTemplate(col, item)">
</span>
+ <span ng-if="col.template && col.compiled" style="padding-left:5px; padding-right:10px;"
+ compile="col.template">
+ </span>
+
<!-- otherwise, simply display the item value, which may
pass through datatype-specific filtering. -->
<span ng-if="!col.template" style="padding-left:5px; padding-right:10px;">
// optional: for non-IDL columns, specifying a datatype
// lets the caller control which display filter is used.
// datatype should match the standard IDL datatypes.
- datatype : '@'
+ datatype : '@',
+
+ // optional hash of functions that can be imported into
+ // the directive's scope; meant for cases where the "compiled"
+ // attribute is set
+ handlers : '='
},
link : function(scope, element, attrs, egGridCtrl) {
angular.forEach(
[
'visible',
+ 'compiled',
'hidden',
'sortable',
'nonsortable',
linkpath : colSpec.linkpath,
template : colSpec.template,
visible : colSpec.visible,
+ compiled : colSpec.compiled,
+ handlers : colSpec.handlers,
hidden : colSpec.hidden,
datatype : colSpec.datatype,
sortable : colSpec.sortable,
};
})
+/* https://stackoverflow.com/questions/17343696/adding-an-ng-click-event-inside-a-filter/17344875#17344875 */
+.directive('compile', ['$compile', function ($compile) {
+ return function(scope, element, attrs) {
+ // pass through column defs from grid cell's scope
+ scope.col = scope.$parent.col;
+ scope.$watch(
+ function(scope) {
+ // watch the 'compile' expression for changes
+ return scope.$eval(attrs.compile);
+ },
+ function(value) {
+ // when the 'compile' expression changes
+ // assign it into the current DOM
+ element.html(value);
+
+ // compile the new DOM and link it to the current
+ // scope.
+ // NOTE: we only compile .childNodes so that
+ // we don't get into infinite loop compiling ourselves
+ $compile(element.contents())(scope);
+ }
+ );
+ };
+}])
+
/**