Skip to content

Stepper editor ​

cellEditor: 'stepper' adds increase and decrease buttons to a number input. It suits values changed one notch at a time, such as a quantity or a level. You can still type a number, or change it with the buttons or the arrow keys.

ts
{ id: 'qty', kind: 'number', editable: true, cellEditor: 'stepper',
  editorParams: { step: 1, min: 0, max: 99 } }

It needs the optional editors bundle (maxgrid/editors in the modular build). Without the bundle, creating the grid fails with invalid-option. The number input rules from Cell editing (decimals and the others) work as usual.

Options ​

All go in editorParams. Defaults apply when omitted.

OptionValueDefaultEffect
stepnumber greater than 01Size of one step
minnumbernoneSmallest value; buttons and keys stop here
maxnumbernoneLargest value; a max below min is an invalid-option
repeat0 or integer 30-500 (ms)80Repeat interval while a button is held; 0 means no repeat
layout'sides' · 'stacked''sides'sides is − input +, stacked puts ▲▼ at the right of the input
typingbooleantruefalse makes the input read-only; only the buttons and keys change it
decimalsinteger 0-10noneDecimal places of the result; without it, the larger of step and the value

The shared input attributes (inputMode, align, placeholder) work as well. An unknown key or a wrong value is an invalid-option when the grid is created (for example step: 0).

Keyboard and buttons ​

InputEffect
↑ · ↓Increase or decrease by step
PageUp · PageDownIncrease or decrease by 10 times step
Home · EndJump to min or max (nothing happens when neither is set)
Pressing a buttonOne step; held for over 400 ms it repeats every repeat ms
EscStops the repeat and cancels the edit

The buttons are not tab stops (tabindex="-1"); keyboard users press the arrow keys in the input. The input has role="spinbutton" with aria-valuenow, aria-valuemin and aria-valuemax, and the buttons are named in the grid language ("Increase qty"). At a limit, that button gets disabled and aria-disabled.

An empty value starts from min (or 0) and takes one step. The repeat stops when the pointer is released or leaves the button, or when the input loses focus.

Typed values are not corrected ​

If you type a number outside the range, the editor does not quietly change it to min or max. Validation refuses it on commit and shows why (Must be 10 or less.), so keyboard users can see the reason. A validation.min or validation.max you set yourself wins.

See also ​