Polymer Filters and Formatting Data

Referencing the polymer documentation, filters can be used in expressions to transform data: {{ expression | filterName([optional parameters]}}

To use a filter in one of your sortable-table templates, it must be registered into the PolymerExpressions scope, which is accessible after polymer has loaded:

window.addEventListener('polymer-ready', function(){ PolymerExpressions.prototype.myFilter = function(){ ... } });

If a filter is being used in a rowTemplate or rowEditorTemplate and references more than one field, it might be useful to pass the row as an argument: {{ record.row | myFilter }} however, this won't automatically observe the individual fields of the row. To tell polymer to watch individual fields, they must all be sent as optional parameters: {{ record.row | myFilter(record.row.myField1, record.row.myField2) }}

The added benefit is that the function can be reused in rowTemplates and as a column.formula:

function myFilter(row){ return [your logic here]; } ... PolymerExpressions.prototype.myFilter = myFilter ... //in the columns array { name:'field1', formula: myFilter }