FreeGridv1.15.1한국어

Number editor

A number box with ▲▼ buttons and arrow-key steps, Shift for ten steps, decimal steps without rounding errors, and min / max limits checked on edit, paste and fill.

Live demoNumber editor

Steps, Shift ×10, decimals and min / max messages.

Code for this demo
import { createGrid, type ColumnDef, type Row } from '@freegridjs/core';
import { makeRows } from '../data';
import { button, separator, text, tr, type DemoContext } from '../ui';

export default function mount(ctx: DemoContext) {
  const h = (en: string, ko: string) => tr(ctx.lang, { en, ko });
  const data = makeRows(150).map((r, i) => ({ ...r, qty: i % 40, rate: Math.round((i % 20) * 5) / 100, rating: (i % 11) / 2 }));
  const grid = createGrid(ctx.host, {
    columns: [
      { field: 'name', header: h('Name', '이름'), width: 150 },
      { field: 'qty', header: h('Qty (0–99)', '수량(0~99)'), type: 'number', width: 120, editable: true, editor: { type: 'number', min: 0, max: 99 } },
      { field: 'rate', header: h('Rate (step 0.05)', '비율(0.05씩)'), type: 'number', format: '0.00', width: 140, editable: true, editor: { type: 'number', min: 0, max: 1, step: 0.05 } },
      { field: 'rating', header: h('Rating (0–5, 0.5)', '평점(0~5, 0.5씩)'), type: 'number', format: '0.0', width: 150, editable: true, editor: { type: 'number', min: 0, max: 5, step: 0.5 } },
    ],
    data, locale: ctx.lang,
  });
  grid.on('validationFailed', e => ctx.log(`refused ${String(e.value ?? '')}: ${e.message}`));
  text(ctx, h('Double-click a number: ↑ ↓ or ▲▼ step, Shift ×10. Type a value outside the range to see the message.',
    '숫자를 더블클릭하세요. ↑ ↓나 ▲▼로 단계, Shift는 10배. 범위 밖 값을 입력하면 안내가 나옵니다.'));
  separator(ctx);
  // pasting follows the same min / max rule as typing
  const paste = (v: number) => {
    grid.setRange({ start: { rowIndex: 0, colId: 'qty' }, end: { rowIndex: 0, colId: 'qty' } });
    const r = grid.pasteText(String(v));
    ctx.log(r.changed
      ? h(`${v} is within 0–99: pasted into row 1`, `${v}은(는) 0~99 범위 안이라 1행에 붙여넣었습니다`)
      : h(`${v} is outside 0–99: not pasted (skipped ${r.skipped} cell)`, `${v}은(는) 0~99 범위를 벗어나 붙여넣지 않았습니다 (건너뜀 ${r.skipped}칸)`));
  };
  button(ctx, h('Paste 50 into row 1 (accepted)', '1행에 50 붙여넣기 (허용)'), () => paste(50));
  button(ctx, h('Paste 150 into row 1 (refused)', '1행에 150 붙여넣기 (거부)'), () => paste(150));
  return grid;
}

Number columns (type: 'number') edit in a text box that accepts 1,234, ₩5,000 and the like. editor: { type: 'number', min, max, step } adds ▲▼ buttons, arrow-key steps and limits.

Basic use

const columns = [
  { field: 'qty', type: 'number', editable: true, editor: { type: 'number', min: 0, max: 999 } },
  { field: 'rate', type: 'number', format: '0.00', editable: true, editor: { type: 'number', min: 0, max: 1, step: 0.05 } },
  { field: 'rating', type: 'number', format: '0.0', editable: true, editor: { type: 'number', min: 0, max: 5, step: 0.5 } },
];

Keyboard and mouse

KeyDoes
↑ / ↓One step up / down (stays inside min – max)
Shift + ↑ / ↓Ten steps
▲ / ▼ buttonsOne step (the keyboard focus stays in the box)
Enter / Tab / EscSave and move / save and next cell / cancel

Options

NameTypeDescription
min / maxnumberLimits. A typed, pasted or filled value outside them is refused with the message 'Enter a value from {min} to {max}' (translated); validate() reports it too.
stepnumberThe size of one step (default 1). Decimal steps add exactly: 0.1 + 0.2 shows 0.3.

Limits everywhere

  • Typing: the editor stays open with the message under the cell until the value fits.
  • Paste and fill handle: values outside the range are skipped and counted.
  • validate() and validateCell() list cells outside the range (see Validation).
  • Only one bound is fine: { min: 0 } says "from 0 to ∞".