4

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
  • Share what you've tried so far Commented Mar 19, 2015 at 13:31

1 Answer 1

8

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).

Sign up to request clarification or add additional context in comments.

3 Comments

Quite a few on the code examples on that page are currently showing 'Not Found' or a blank frame.
@ColtMcCormack My apologies! Looks like there was http/https mixed content that was being blocked. All the plunker examples should be working now.
I had to use scope.$parent.$parent.row.entity. Seems a little hacky, but I do have some grouping done in my grid though, not sure if that's why.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.