Reputation: 61
I would like to execute a cellFilter to programatically define what needs to be displayed within a cell. When defining the column definitions you need to specify what field the cell corresponds with, however I need access to the entire row of data within the cellFilter, not just a single field. Is it possible to pass multiple fields to a filter, or the entire row?
{
name: 'To',
field: 'myData',
cellFilter: 'formatCaller'
}
Thank you.
Upvotes: 4
Views: 6076
Reputation: 3012
Yes, passing this
as an argument to your filter sends the current scope
cellFilter: 'formatCaller:this`
Then in your filter you can access the row like so:
app.filter('formatCaller', function () {
return function (value, scope) {
return scope.row.entity.whateverField + ' ' + yourFormattingFunction(value);
};
});
You can find a deeper explanation (and a plunker demo) here: http://brianhann.com/6-ways-to-take-control-of-how-your-ui-grid-data-is-displayed/ (caveat: I'm the author).
Upvotes: 8