# Numeric Cell Editor

Canonical page: https://www.adaptabletools.com/docs/handbook-cell-editors-numeric

- Numeric Cell Editor is provided by AdapTable whenever a numeric cell is edited
- It is also used when filtering a numeric column

The Numeric Cell Editor is used, by default in AdapTable, when editing all numeric Columns.

A numeric column is one where the [Cell Data Type](https://www.adaptabletools.com/docs/dev-guide-aggrid-cell-data-types/index.md) is set to `number`.

It is also used when a [FreeText Column](https://www.adaptabletools.com/docs/handbook-freetext-column/index.md) is defined as numeric

It displays an editor with arrows at the end to move up and down and only accepts numbers (with fractions).

The Numeric Cell Editor will take into account any [Shortcuts](https://www.adaptabletools.com/docs/handbook-editing-shortcut/index.md) that have been created

## Cell Editor Params

The Numeric Cell Editor can be configured by specifying `cellEditorParams` in the AG Grid Column Definition.

This maps to the [`AdaptableNumberCellEditorParams`](https://www.adaptabletools.com/docs/reference/adaptablenumbercelleditorparams.md) object and contains 2 main properties:

- `showClearButton` - specifies whether to show the *Clear* button in the Editor

If set to `true` (the default value), it works together with `emptyValue`

- `emptyValue` - value to set in a cell when the Clear button is pressed (defaults to an empty string)

- Some AG Grid Column Definitions have a `valueParser` which is provided as a function
- In that use case, the function will be invoked **before** setting the value for the cell

**Example: Numeric Cell Editor Params**

Numeric Editor with Cell Editor Params

- This demo illustrates how to use the Numeric Cell Editor. For the `GitHub Stars` column, we provide 2 Cell Editor Params:
  - `showClearButton` is set to *true* so we see a Clear Button (that is the default behaviour anyway)
  - `emptyValue` has been set to `1000` (instead of the default empty string)

- Clear a cell in the Numeric Editor in the `GitHub Stars` column and note how the edit value changes to 1000

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Numeric Editor Params',
  initialState: {
    Dashboard: {
      ModuleButtons: ['FormatColumn'],
    },

    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'created_at',
            'updated_at',
            'pushed_at',
            'description',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```
**`src/columnDefs.ts`**

```ts
import {ColDef} from 'ag-grid-enterprise';

export const columnDefs: ColDef[] = [
  {
    field: 'name',
    cellDataType: 'text',
  },

  {
    field: 'language',
    cellDataType: 'text',
    enablePivot: true,
    enableRowGroup: true,
  },
  {
    field: 'github_stars',
    headerName: 'GitHub Stars',
    cellDataType: 'number',
    enableValue: true,
    cellEditorParams: {
      emptyValue: 1000,
      showClearButton: true,
    },
  },
  {
    field: 'license',
    cellDataType: 'text',
    editable: true,
    enablePivot: true,
    enableRowGroup: true,
  },
  {
    field: 'week_issue_change',
    headerName: 'Issue Change',
    cellDataType: 'number',
    enableValue: true,
  },
  {
    field: 'created_at',
    headerName: 'Created',
    cellDataType: 'date',
  },
  {field: 'has_wiki', headerName: 'Has Wiki', cellDataType: 'boolean'},
  {
    field: 'updated_at',
    headerName: 'Updated',
    cellDataType: 'date',
  },
  {
    field: 'pushed_at',
    headerName: 'Pushed',
    cellDataType: 'date',
  },
  {
    field: 'github_watchers',
    headerName: 'GitHub Watchers',
    cellDataType: 'number',
    enableValue: true,
  },

  {
    field: 'topics',
    cellDataType: 'textArray',
    editable: false,
    sortable: false,
  },
  {
    field: 'open_issues_count',
    headerName: 'Open Issues',
    cellDataType: 'number',
    enableValue: true,
  },
  {
    field: 'closed_issues_count',
    headerName: 'Closed Issues',
    cellDataType: 'number',
    enableValue: true,
  },
  {
    field: 'description',
    cellDataType: 'text',
    sortable: false,
  },

  {
    field: 'open_pr_count',
    headerName: 'Open PRs',
    cellDataType: 'number',
    enableValue: true,
  },
  {
    field: 'closed_pr_count',
    headerName: 'Closed PRs',
    cellDataType: 'number',
    enableValue: true,
  },
  {field: 'has_projects', headerName: 'Has Projects', cellDataType: 'boolean'},
  {field: 'has_pages', headerName: 'Has Pages', cellDataType: 'boolean'},
  {
    field: 'id',
    cellDataType: 'number',
    hide: true,
    editable: false,
  },
];
```
