@serenity-is/sleekgrid / FormatterContext
Interface: FormatterContext<TItem>
Defined in: src/core/formatting.ts:11
Context object for column formatters. It provides access to the current cell value, row index, column index, etc. Use grid.getFormatterContext() or the
See
formatterContext helper to create a new instance.
Type Parameters
TItem
TItem = any
Properties
addAttrs?
optionaladdAttrs:object
Defined in: src/core/formatting.ts:16
Additional attributes to be added to the cell node.
Index Signature
[key: string]: string
addClass?
optionaladdClass:string
Defined in: src/core/formatting.ts:21
Additional classes to be added to the cell node.
cell?
optionalcell:number
Defined in: src/core/formatting.ts:46
The column index of the cell.
column?
optionalcolumn:Column<TItem>
Defined in: src/core/formatting.ts:51
The column definition of the cell.
enableHtmlRendering
readonlyenableHtmlRendering:boolean
Defined in: src/core/formatting.ts:29
True if the formatter is allowed to return raw HTML that will be set using innerHTML. This is set from grid options and defaults to true for backward compatibility. When set to false, the formatter should return plain text and the result will be set using textContent and the escape() method is a noop in that case.
grid?
optionalgrid:ISleekGrid
Defined in: src/core/formatting.ts:56
The grid instance.
item?
optionalitem:TItem
Defined in: src/core/formatting.ts:61
The item of the row.
purpose?
optionalpurpose:"print"|"auto-width"|"excel-export"|"group-header"|"grand-totals"|"group-totals"|"header-filter"|"pdf-export"
Defined in: src/core/formatting.ts:66
Purpose of the call, e.g. "auto-width", "excel-export", "group-header", "header-filter", "pdf-export", "print".
row?
optionalrow:number
Defined in: src/core/formatting.ts:41
The row index of the cell.
sanitizer()
sanitizer: (
dirtyHtml) =>string
Defined in: src/core/formatting.ts:71
Sanitizer function to clean up dirty HTML.
Parameters
dirtyHtml
string
Returns
string
tooltip?
optionaltooltip:string
Defined in: src/core/formatting.ts:76
Tooltip text to be added to the cell node as title attribute.
value?
optionalvalue:any
Defined in: src/core/formatting.ts:79
when returning a formatter result as HTML string, prefer ctx.escape() to avoid script injection attacks!
Methods
escape()
escape(
value?):string
Defined in: src/core/formatting.ts:36
Returns html escaped ctx.value if called without arguments. Prefer this over ctx.value when returning as HTML string to avoid html injection attacks!
- Note that when enableHtmlRendering is false, this is simply a noop and returns the value as string.
Parameters
value?
any
Returns
string