如何在angular-ui-grid cellFilter中访问整个行数据 [英] How to access entire row data in angular-ui-grid cellFilter

查看:183
本文介绍了如何在angular-ui-grid cellFilter中访问整个行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行cellFilter以编程方式定义需要在单元格中显示的内容.在定义列定义时,您需要指定单元格对应的字段,但是我需要访问cellFilter内的整个数据行,而不仅仅是单个字段.是否可以将多个字段传递给过滤器或整个行?

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'
}

谢谢.

推荐答案

是的,将this作为参数传递给过滤器会发送当前范围

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);
  };
});

您可以在此处找到更深入的说明(和插件演示):http://brianhann.com/6-ways-to-take-control-of-how-your-ui-grid-data-is-displayed/(注意:我是作者).

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

这篇关于如何在angular-ui-grid cellFilter中访问整个行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆