# Providing Custom Column Values when Editing

Canonical page: https://www.adaptabletools.com/docs/handbook-editing-custom-column-values

- AdapTable usually fetches a Column's distinct values when using the [Select Cell Editor](https://www.adaptabletools.com/docs/handbook-cell-editors-select/index.md) or [Bulk Update dropdown](https://www.adaptabletools.com/docs/handbook-editing-bulk-update/index.md)
- Developers are able to override this default behaviour by providing a bespoke list of custom values

By default, when using the [Select Cell Editor](https://www.adaptabletools.com/docs/handbook-cell-editors-select/index.md) or the [Bulk Update dropdown](https://www.adaptabletools.com/docs/handbook-editing-bulk-update/index.md), AdapTable will loop through all the values in AG Grid for that column, retrieving and then displaying all the distinct items.

- The default list is the Column's distinct raw values
- If the data contains both `"EUR"` and `"eur"`, both appear

Alternatively developers can supply a list of bespoke, custom values to be displayed instead.

This is provided using the `customEditColumnValues` property in [Edit Options](https://www.adaptabletools.com/docs/technical-reference-editing/index.md).

### `customEditColumnValues`

Provide custom list of values to display in Edit controls

  [`CustomEditColumnValueInfo[]`](https://www.adaptabletools.com/docs/reference/customeditcolumnvalueinfo.md)

Use this property to change the list shown by AdapTable when using Edit controls that display distinct column values.

It is a function that receives a [`CustomEditColumnValuesContext`](https://www.adaptabletools.com/docs/reference/customeditcolumnvaluescontext.md) object and returns a [`CustomEditColumnValueInfo`](https://www.adaptabletools.com/docs/reference/customeditcolumnvalueinfo.md) array.

The function can also be run asynchronously to return a `Promise<CustomEditColumnValueInfo[]>` if required

The `CustomEditColumnValuesContext` object **received** by the function is defined as follows:

| Property | Type | Description |
| --- | --- | --- |
| [currentSearchValue](https://www.adaptabletools.com/docs/reference/customeditcolumnvaluescontext.md#currentsearchvalue) | `string` | Search text in Edit - used when fetching values from server |
| [defaultValues](https://www.adaptabletools.com/docs/reference/customeditcolumnvaluescontext.md#defaultvalues) | `Required<`[`CustomEditColumnValueInfo`](https://www.adaptabletools.com/docs/reference/customeditcolumnvalueinfo.md)`>[]` | Current distinct values in Column |
| [gridCell](https://www.adaptabletools.com/docs/reference/customeditcolumnvaluescontext.md#gridcell) | [`GridCell`](https://www.adaptabletools.com/docs/reference/gridcell.md) | Currently edited Grid Cell |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/customeditcolumnvaluescontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

The `CustomEditColumnValueInfo` object **returned** by the function (as an array) is defined as follows:

| Property | Type | Description |
| --- | --- | --- |
| [label](https://www.adaptabletools.com/docs/reference/customeditcolumnvalueinfo.md#label) | `string` | Text shown for this item. The value is shown when this is omitted. |
| [value](https://www.adaptabletools.com/docs/reference/customeditcolumnvalueinfo.md#value) | `any` | Value written into the cell when this item is chosen. |

**Example: Edit Custom Values**

Providing custom values when editing a Column

 

- In this Demo we provide custom editing values for 2 Columns by using the `customEditColumnValues` property:
  - `License` - returns 'Permissive', 'LGPL', 'MIT', 'Public Domain'
  - `Language` — returns a different list for rows where `license` is not *MIT License*
- Note: we provide a [Select Cell Editor](https://www.adaptabletools.com/docs/handbook-cell-editors-select/index.md) for both columns

- Click in a cell in either Column to see the bespoke values
- Attempt a Bulk Update on either Column to see the same bespoke values

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

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts
  gridOptions.ts
  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: 'Select Editor Data',
  editOptions: {
    showSelectCellEditor: context => {
      return (
        context.column.columnId === 'license' ||
        context.column.columnId === 'language'
      );
    },
    customEditColumnValues: context => {
      if (context.column.columnId === 'license') {
        return [
          {label: 'Permissive', value: 'Permissive'},
          {label: 'LGPL', value: 'LGPL'},
          {label: 'MIT', value: 'MIT'},
          {label: 'Public Domain', value: 'Public Domain'},
        ];
      }
      if (context.column.columnId === 'language') {
        return context.gridCell?.rowNode.data['license'] == 'MIT License'
          ? [
              {label: 'JavaScript', value: 'JavaScript'},
              {label: 'TypeScript', value: 'TypeScript'},
            ]
          : [
              {label: 'HTML', value: 'HTML'},
              {label: 'XML', value: 'XML'},
              {label: 'CSS', value: 'CSS'},
            ];
      }
      return context.defaultValues;
    },
  },
  initialState: {
    Dashboard: {PinnedToolbars: ['BulkUpdate']},
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'license',
            'language',
            'week_issue_change',
            'github_watchers',
            'github_stars',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'open_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```
**`src/columnDefs.ts`**

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

export const columnDefs: ColDef[] = [
  {
    field: 'id',
    cellDataType: 'number',
    hide: true,
    editable: false,
  },
  {
    field: 'name',
    cellDataType: 'text',
  },

  {
    field: 'language',
    cellDataType: 'text',
    enablePivot: true,
    enableRowGroup: true,
  },
  {
    field: 'github_stars',
    headerName: 'GitHub Stars',
    cellDataType: 'number',
    enableValue: 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'},
];
```
**`src/gridOptions.ts`**

```ts
import {GridOptions, themeBalham} from 'ag-grid-enterprise';

import {rowData} from './rowData';
import {columnDefs} from './columnDefs';

export const gridOptions: GridOptions = {
  theme: themeBalham,
  defaultColDef: {
    resizable: true,

    sortable: true,
    editable: true,
    filter: true,
    floatingFilter: true,
  },
  columnDefs: columnDefs,
  rowData: rowData,
  sideBar: true,
  suppressMenuHide: true,
  cellSelection: true,
  singleClickEdit: true,
  statusBar: {
    statusPanels: [
      {statusPanel: 'agTotalRowCountComponent', align: 'left'},
      {statusPanel: 'agFilteredRowCountComponent'},
      {
        key: 'Center Panel',
        statusPanel: 'AdaptableStatusPanel',
        align: 'center',
      },
    ],
  },
};
```
