问题
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.
回答1:
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).
来源:https://stackoverflow.com/questions/29145920/how-to-access-entire-row-data-in-angular-ui-grid-cellfilter