# Select Editor

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

- The Select Editor wraps the AG Grid Rich Select Editor, and displays automatically when a cell is being edited
- By default the Select Editor will contain the current distinct values in the column
- However, if required, a different set of values can be provided by developers for the user to see

AdapTable can be configured to display the [AG Grid Rich Select Editor](https://www.ag-grid.com/javascript-data-grid/provided-cell-editors-rich-select/) dynamically during a cell edit.

The Column must be configured as **editable** in the AG Grid column schema for the Select Editor to appear

The `showSelectCellEditor` property in [Edit Options](https://www.adaptabletools.com/docs/technical-reference-editing/index.md) defines which Columns will display a Select Editor.

### `showSelectCellEditor`

Which Columns use a Select Editor

Option used to configure which Columns use AG Grid's Rich Select Editor when being edited.

The property is a function that receives [`AdaptableColumnContext`](https://www.adaptabletools.com/docs/reference/adaptablecolumncontext.md) and returns a boolean.

The `AdaptableColumnContext` simply provides the current Column: 

| Property | Type | Description |
| --- | --- | --- |
| [column](https://www.adaptabletools.com/docs/reference/adaptablecolumncontext.md#column) | [`AdaptableColumn`](https://www.adaptabletools.com/docs/reference/adaptablecolumn.md)`<TData>` | The current Column |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/adaptablecolumncontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

```ts {3}
editOptions: {
  // Display Select Editors for the License and Language columns
  showSelectCellEditor: context => {
    return context.column.columnId === 'license' || context.column.columnId === 'language';
  }
},
```

**Example: Select Editors**

Providing Select Editors to speed up data entry

 

- In this example Select Editors are configured for 2 Columns - `license` and `language` 
- Both Columns display a dropdown when a cell is clicked

- Click on a cell in the `license` or `language` columns and see how a dropdown appears showing the distinct values in the column

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 Editors',
  editOptions: {
    showSelectCellEditor: context => {
      return (
        context.column.columnId === 'language' ||
        context.column.columnId === 'license'
      );
    },
  },
  initialState: {
    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',
      },
    ],
  },
};
```

## Custom Editor Values

By default the Select Editor will automatically display a list of the **distinct** values in that column.

However it is possible to provide a bespoke list of items to display in the Select Editor.

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

See [Providing Custom Column Values when Editing](https://www.adaptabletools.com/docs/handbook-editing-custom-column-values/index.md) for more information and a demo

## Row Forms

AdapTable provides [Row Forms](https://www.adaptabletools.com/docs/handbook-row-form/index.md) to enable safe and easy editing via a dynamic Form.

Any Select Editors which have been provided are also available when editing the cell using Row Forms.

The Select Editor is also displayed when using `Create` or `Clone` in a Row Form
