How to access entire row data in angular-ui-grid cellFilter

拟墨画扇 提交于 2019-12-22 09:09:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!