0

I use a cell filter to show multiple properties of a bound entity in one cell. Therefore there is no one field name because it is a computed field. How can I force the grid to reevaluate the cell filter if one of the involved properties changes?

The column definition:

columnDefs: [
  { field: 'xxx', displayName: 'Something', cellFilter: 'concatSomeProps:this' }
]

The filter:

myApp.filter('concatSomeProps', function () {
  return function (cellValue, scope) {
    var entity = scope.row.entity;
    return entity.prop1 + ", " + entity.prop2;
  };
});

If have tried to use notifyDataChanged or the refresh function of the grid api but it doesn't work.

KreepN
  • 8,528
  • 1
  • 40
  • 58
Tobias J.
  • 1,043
  • 12
  • 31

1 Answers1

0

I'd probably use a cellTemplate, and not a filter in this case:

{ field: 'xxx', displayName: 'Something', cellTemplate:'template.html' }

And

<script type="text/ng-template" id="template.html">
   <div>
       {{row.entity.name + row.entity.age}}
   </div>
</script>

See this Plnkr I made for you to see what I'm talking about. Edit either one of the first two fields and you will see the concat field change. You'd also change your template to use row.entity.prop1 + row.entity.prop2 to make it work, as my template is for my columns.

KreepN
  • 8,528
  • 1
  • 40
  • 58