我想执行一个 cellFilter 以编程方式定义需要在单元格中显示的内容。在定义列定义时,您需要指定单元格对应的字段,但是我需要访问 cellFilter 中的整行数据,而不仅仅是单个字段。是否可以将多个字段或整行传递给过滤器?
{
name: 'To',
field: 'myData',
cellFilter: 'formatCaller'
}
谢谢你。
最佳答案
是的,路过this
作为过滤器的参数发送当前范围
cellFilter: 'formatCaller:this`
然后在您的过滤器中,您可以像这样访问该行:
app.filter('formatCaller', function () {
return function (value, scope) {
return scope.row.entity.whateverField + ' ' + yourFormattingFunction(value);
};
});
您可以在此处找到更深入的解释(和 plunker 演示):http://brianhann.com/6-ways-to-take-control-of-how-your-ui-grid-data-is-displayed/ (警告:我是作者)。
关于angularjs - 如何访问angular-ui-grid cellFilter中的整行数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29145920/