UI-过滤器选项的网格设置模板

UI-Grid setting template for filter options

我用 UI-Grid 创建了一个 table,上面有多个 select 过滤器。一切正常。

但是,我对一列使用了 cellTemplate,因为我需要正确格式化值(金钱)。我有一个函数,我将值通过管道传递给它,returns 它的格式很好:

cellTemplate: '<div class="ui-grid-cell-contents">{{COL_FIELD | moneyFormatter }}</div>'

过滤器中的值会自动填充,但它使用原始值,而不是格式良好的值。我需要在那里获取格式化值。

我知道你在 columnDefs 中设置的 selectOptions。但据我所知,它需要一个预先确定的原始值和翻译列表。

有没有办法将某种函数传递给 selectOptions?有没有办法为<option>设置模板,类似于cellTemplate?或者还有其他方法吗?

你应该利用 headerCellFilter

来自文档:

headerCellFilter is a filter to apply to the content of the column header

对于您想要设置下拉列表格式的列,您可以在 columnDefs-

中执行此操作
{field:'id', displayName:'ID', headerCellFilter:'moneyFormatter'}