diff --git a/aurelia-slickgrid/src/aurelia-slickgrid/formatters/multipleFormatter.ts b/aurelia-slickgrid/src/aurelia-slickgrid/formatters/multipleFormatter.ts index 0b83bc36e..c6a299832 100644 --- a/aurelia-slickgrid/src/aurelia-slickgrid/formatters/multipleFormatter.ts +++ b/aurelia-slickgrid/src/aurelia-slickgrid/formatters/multipleFormatter.ts @@ -1,15 +1,18 @@ import { Column, Formatter } from './../models/index'; -export const multipleFormatter: Formatter = (row: number, cell: number, value: any, columnDef: Column, dataContext: any) => { +export const multipleFormatter: Formatter = (row: number, cell: number, value: any, columnDef: Column, dataContext: any, grid: any) => { const params = columnDef.params || {}; if (!params.formatters || !Array.isArray(params.formatters)) { throw new Error(`The multiple formatter requires the "formatters" to be provided as a column params. For example: this.columnDefinitions = [{ id: title, field: title, formatter: Formatters.multiple, params: { formatters: [Formatters.lowercase, Formatters.uppercase] }`); } const formatters: Formatter[] = params.formatters; - let formattedValue = ''; + + // loop through all Formatters, the value of 1st formatter will be used by 2nd formatter and so on. + // they are piped and executed in sequences + let currentValue = value; for (const formatter of formatters) { - formattedValue = formatter(row, cell, value, columnDef, dataContext); + currentValue = formatter(row, cell, currentValue, columnDef, dataContext, grid); } - return formattedValue; + return currentValue; };