Skip to content

Header renderers and renaming ​

How to put a button or a checkbox in a column header, add your own element, and let users edit the title in place (1.4.0). Without the keys below the header is exactly as before.

ts
{ id: 'status', title: 'Status', headerRenderer: 'button',
  headerRendererParams: { label: 'Complete all', onClick: ({ columnId }) => markAllDone(columnId) } }

Header renderer (headerRenderer) ​

ValueMeaning
'button'One button next to the title
'checkbox'One checkbox next to the title (on any column, separate from the selection column)
HeaderAdapterFactoryYour own renderer: () => ({ mount(el, ctx), update?(ctx), destroy?() })

The control sits next to the title (position), and pressing or typing in it does not sort, drag, resize or open the column menu, because pointerdown, mousedown, click, dblclick and keydown stop at the control area.

button params (headerRendererParams) ​

KeyValueDefaultEffect
onClick({ columnId, event }) => voidrequiredOn press; a throw is reported as an error event (callback-error)
labelstringcolumn titleButton text and aria-label
position'start' · 'end''end'Before / after the title
disabledboolean or ({ columnId }) => booleanfalseBlocks it; sets disabled and aria-disabled, and onClick is not called
editablebooleanfalseRename the title (below)

checkbox params ​

KeyValueDefaultEffect
onChange(checked, { columnId }) => voidrequiredWhen it changes
checkedboolean or ({ columnId }) => boolean | 'indeterminate'falseEvaluated when drawn; 'indeterminate' is the partial look
canCheck({ columnId }) => booleannoneReturning false reverts the change
position'start' · 'end''start'Before / after the title
editablebooleanfalseRename the title

Values do not update by themselves after drawing. When your state changes, tell the grid with api.setHeaderRendererParams(id, { ...params, checked: true }). It is updateColumn(id, { headerRendererParams }), with the same validation and redraw (it needs the columns bundle).

Custom renderer ​

CallWhen
mount(el, ctx)Once, when first drawn; ctx is { columnId, column, api, params }
update(ctx)When the header is redrawn (width or order change, params change); the same element is moved to the new header cell so its state stays
destroy()When the column is removed, the renderer changes, horizontal virtualization takes it out of the window, or the grid is destroyed

A throw in any of the three is reported as an error event (callback-error) and the header is still drawn.

Header dropdown (headerRenderer: 'dropdown') ​

Puts a button in the header that picks a value from a list. Your app receives the value and uses it to change a filter or a view.

ts
{
  id: 'team',
  title: 'Team',
  headerRenderer: 'dropdown',
  headerRendererParams: {
    options: [{ value: 'all', label: 'All' }, { value: 'dev', label: 'Dev' }],
    value: 'all',
    onSelect: ({ value }) => applyTeamFilter(value),
  },
}
Property (headerRendererParams)Description
optionsAn array of { value, label }, or a function called every time the list opens. Required.
valueThe chosen value (null means none). A new params object from setHeaderRendererParams takes its value.
placeholderButton text when nothing is chosen. Default is "선택" or "Select".
onSelectReceives ({ columnId, value, label }). If it throws, the grid keeps running and an error event fires.
applyToTitleWhen true the button reads "column title: chosen label" (title only before a pick) and the header title text is hidden. Default false.
maxHeightMaximum list height in px. Default 240; longer lists scroll inside.
alignHorizontal alignment of the list ('start' or 'end'). Default 'start'.
disabledWhen true the button does nothing.
positionPlace it before ('start') or after ('end', default) the title.
  • Choosing also fires one headerDropdownChanged { columnId, value, label } event.
  • Click the button, or press Enter, Space or Down, to open the list. Move with Up, Down, Home, End or the first letter, choose with Enter, close with Esc. A click outside closes it too.
  • When there is no room below, the list flips above the button; on narrow screens it opens as a bottom sheet.
  • Clicking the header does not sort. Redrawing the header (a width change and so on) closes an open list.

Keyboard ​

Controls add no tab stops (tabindex="-1"). With the header focused (focusHeader), Enter and Space press the built-in button or checkbox when the column has one and sorting is not enabled for it. On a sortable column Enter and Space sort (the control is pressed by mouse or touch).

Renaming the title ​

With titleEditable: true on a column (1.5.0, no header renderer needed) a double click on the title edits it in place, and F2 with the header focused opens it too. The earlier headerRendererParams: { editable: true } (alone, without a renderer, also works) still turns it on. It is off by default.

ts
{ id: 'name', title: 'Name', titleEditable: true }
ActionResult
Double click, F2An input opens in place of the title (up to 120 characters)
Enter, losing focusCommits: updateColumn(id, { title }), then headerRenamed { columnId, title } only when the title changed
EscCancels
Same textNo change
Empty textRejected: Enter keeps the input open with an error mark, losing focus restores the old title
beforeColumnChange hookCalled with type: 'update'; false keeps the title and sends no event
IME inputEnter and Esc are ignored while composing; Enter after the composition ends commits
  • Saving: a changed title goes into the title of getColumnState(). It is present only for columns whose title differs from the initial one; setColumnState() and initialState apply it (through beforeColumnChange), and resetColumnState() restores the initial title. Details are in Save and restore state.
  • Elsewhere: export headers, header copy, find and the accessible name (aria) read the new title.
  • Unchanged: sorting, dragging and resizing do not start from the input, and columns with a header renderer (button, checkbox, dropdown) keep working.

Header title state example

Computed title and tooltip (headerTitle, headerTooltipFor) ​

headerTitle: ({ columnId }) => string and headerTooltipFor are called when drawing and win over title and headerTooltip. If one throws, an error is reported and title or headerTooltip is used. They change the header text only; the column menu and exports still use title.

Merged header cells (headerSpan) ​

KeyMeaning
colsHow many neighbouring columns this header spans horizontally (1-64); the covered headers are not drawn
rowsWith headerGroups, how many header rows the column header occupies; more than the rows left means all the way down

cols is ignored when a pinned column would be spanned or the last column would be passed. With grouped headers only rows applies. A value that is not an integer from 1 to 64 is an invalid-option.

Errors ​

SituationError
headerRenderer is not 'button', 'checkbox' or a functioninvalid-option
Required onClick or onChange is not a function, unknown key or valueinvalid-option
headerSpan value is not an integer from 1 to 64invalid-option
headerTitle or headerTooltipFor is not a functioninvalid-option

See also ​