# Row Forms

Canonical page: https://www.adaptabletools.com/docs/handbook-row-form

- AdapTable provides dynamic Row Forms to help users to safely manage creating, cloning and editing Rows
- Row Forms are highly configurable to meet all requirements
- Row Form submission can be handled automatically by AdapTable or by listening to Row Form Submitted Event
- Action Column Commands can be used to dynamically open Row Forms

Row Forms allow users safely to manage row-related CRUD operations in AdapTable via a popup Form.

There are 4 Row Forms available (the first 3 each of which are specialised types of [Adaptable Form](https://www.adaptabletools.com/docs/ui-tutorial-configuring-adaptable-forms/index.md)):

- `Create` - opens a completely empty Form with a UI control for each field in the Data Source
- `Clone` - opens a Form with fields displaying copied values from an existing row
- `Edit` - opens a Form showing the current values of the Row
- `Delete` - no visible Form appears, but it fires Row Form Submitted Event to enable safe row deletion

Row Forms are configured in **`rowFormOptions`**. By default **`autoHandle`** is _true_, so AdapTable updates the grid when the user saves; set it to _false_ to handle **`RowFormSubmitted`** yourself.

The usual ways to open a form are **`adaptableApi.rowFormApi`** (dashboard/toolbar buttons) or [Action Column Commands](https://www.adaptabletools.com/docs/handbook-action-column-command/index.md) (`create`, `clone`, `edit`, `delete`) on each row.

## Topics in this Section

| Topic                                                                                    | Summary                                                           |
| ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| This page                                                                                | Create / clone / edit / delete, fields, `autoHandle`, events      |
| [Configuring Row Forms](https://www.adaptabletools.com/docs/handbook-row-form-configuring/index.md)        | Title, included columns, custom buttons, inline edit, primary key |
| [Row Forms Technical Reference](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md) | `rowFormOptions`, **`RowFormSubmitted`**, **`rowFormApi`**        |
| [Action Column Commands](https://www.adaptabletools.com/docs/handbook-action-column-command/index.md)      | Built-in commands that open the matching Row Form                 |

## Displaying Row Forms

Row Forms can be displayed in 2 ways:

- via **`rowFormApi`** on the Adaptable API — see [Row Form API](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md#row-form-api)

`displayCreateRowForm()`, `displayCloneRowForm(primaryKey?)`, `displayEditRowForm(primaryKey)`, and `displayDeleteRowForm(primaryKey?)` (no visible form for delete)

- using [Action Column Commands](https://www.adaptabletools.com/docs/handbook-action-column-command/index.md) in `actionColumnOptions`, which open the matching form when clicked

The `create`, `clone`, `edit` and `delete` commands all invoke the associated Row Form flow

## Create Row Form
The Create Row Form is designed to add entirely new Rows in AdapTable.
The Form displays fields that are based on the existing field and column structure.

There is also a `Clone` Row Form which also creates new Rows but based on an actual existing Row

**Example: Create Row Form**

Displaying the Create Row Form

- This demo displays a Create Row Form in AdapTable:
- In [Dashboard Options](https://www.adaptabletools.com/docs/technical-reference-dashboard/index.md) we provide an "Add New Row" Custom Button and configure the Button's `onClick` event to display the Create Row Form using [Row Form API](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md)
- In [Row Form Options](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md) we provide an implementation for the `setPrimaryKeyValue` function so we can attach a valid primary key to newly created rows
- Additionally we supply a `ROW_ADDED` [Observable Alert](https://www.adaptabletools.com/docs/handbook-alerting-observables/index.md) in [Alert Initial State](https://www.adaptabletools.com/docs/technical-reference-alerting/index.md) which triggers when the Row Form is created

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

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  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 {
  AdaptableButton,
  AdaptableOptions,
  DashboardButtonContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Create Row Form',
  rowFormOptions: {
    setPrimaryKeyValue: context => {
      return {
        ...context.rowData,
        id: context.adaptableApi.gridApi.getRowCount() + 1,
      };
    },
  },
  dashboardOptions: {
    customDashboardButtons: [
      {
        label: 'Add New Row',
        onClick: (
          button: AdaptableButton<DashboardButtonContext>,
          context: DashboardButtonContext
        ) => {
          context.adaptableApi.rowFormApi.displayCreateRowForm();
        },
        buttonStyle: {
          variant: 'raised',
          tone: 'info',
        },
      },
    ],
  },
  initialState: {
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Alert'],
        },
      ],
    },
    Alert: {
      AlertDefinitions: [
        {
          Name: 'alert-info-row-added',
          Rule: 'ROW_ADDED{}',
          MessageType: 'Info',
          Scope: {
            All: true,
          },
          AlertProperties: {
            DisplayNotification: false,
            HighlightRow: {
              BackColor: 'var(--ab-color-palette-28)',
              ForeColor: 'var(--ab-color-palette-14)',
            },
          },
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'edit',
            'name',
            'github_stars',
            'update_stars',
            'week_issue_change',
            'update_issues',
            'github_watchers',
            'license',
            'language',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## Edit Row Form
The Edit Row Form is designed to edit existing Rows in AdapTable in a safe way.
The Form displays fields with values based on the current field and column structure.
**Example: Edit Row Form**

Displaying the Edit Row Form

- This demo displays an Edit Row Form in AdapTable:
- We set an `Edit` Action Column Command in [Action Column Options](https://www.adaptabletools.com/docs/technical-reference-action-column/index.md) to open the Edit Row Form for each row
- In [Row Form Options](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md) we set `disableInlineEditing` to _true_ so that editing is not possible directly in the Grid (i.e. only in the Row Form)
- Additionally we configure AdapTable with these Options and Initial State:
  - In [Edit Options](https://www.adaptabletools.com/docs/technical-reference-editing/index.md) we set the `Language` and `License` Columns to display a [Select Cell Editor](https://www.adaptabletools.com/docs/handbook-cell-editors-select/index.md) (which also appears in the Row Form)
  - In Column Defs we set `Github Stars` to be _readonly_ - this means that it does not display an input in the Row Form
  - In [Flashing Cells](https://www.adaptabletools.com/docs/handbook-flashing-cell/index.md) Initial State we set the Row to flash on any cell change

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: 'Edit Row Form',
  actionColumnOptions: {
    actionColumns: [
      {
        columnId: 'edit',
        friendlyName: 'Edit',
        controls: [{type: 'command', command: 'edit'}],
      },
      {
        columnId: 'delete',
        friendlyName: 'Delete',
        controls: [{type: 'command', command: 'delete'}],
      },
    ],
  },
  rowFormOptions: {
    disableInlineEditing: true,
  },
  editOptions: {
    showSelectCellEditor: context => {
      return (
        context.column.columnId === 'language' ||
        context.column.columnId === 'license'
      );
    },
  },
  initialState: {
    FlashingCell: {
      FlashingCellDefinitions: [
        {
          Name: 'Flashing_Row_Any_Change',
          Scope: {
            All: true,
          },
          Rule: 'ANY_CHANGE()',
          FlashTarget: 'row',
          FlashDuration: 2000,
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Alert: {
      AlertDefinitions: [
        {
          Name: 'alert-info-row-removed',
          Rule: 'ROW_REMOVED{}',
          MessageType: 'Info',
          Scope: {
            All: true,
          },
          AlertProperties: {
            DisplayNotification: true,
          },
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'edit',
            'name',
            'github_stars',
            'update_stars',
            'week_issue_change',
            'update_issues',
            'github_watchers',
            'license',
            'language',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'delete',
          ],
          ColumnPinning: {
            edit: 'left',
            delete: 'right',
          },
          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',
    sortable: true,
  },
  {
    field: 'language',
    cellDataType: 'text',
    enablePivot: true,
    enableRowGroup: true,
  },
  {
    field: 'github_stars',
    headerName: 'GitHub Stars',
    cellDataType: 'number',
    enableValue: true,
    editable: false,
  },
  {
    field: 'license',
    cellDataType: 'text',
    enablePivot: true,
    enableRowGroup: true,
  },
  {
    field: 'created_at',
    headerName: 'Created',
    cellDataType: 'date',
  },
  {
    field: 'has_wiki',
    headerName: 'Has Wiki',
    cellDataType: 'boolean',
    enablePivot: true,
    enableRowGroup: true,
  },
  {
    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: 'open_issues_count',
    headerName: 'Open Issues',
    cellDataType: 'number',
    enableValue: true,
  },
  {
    field: 'closed_issues_count',
    headerName: 'Closed Issues',
    cellDataType: 'number',
    enableValue: true,
  },
  {
    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: 'week_issue_change',
    headerName: 'Issue Change',
    cellDataType: 'number',
    enableValue: true,
  },
];
```

## Clone Row Form
Opens a Clone Row Form based on an existing Row.
The new row is added to the DataGrid.
**Example: Clone Row Form**

Displaying the Clone Row Form

- This demo displays a Clone Row Form in AdapTable:
- We set a `Clone` Action Column Command - with a label - in [Action Column Options](https://www.adaptabletools.com/docs/technical-reference-action-column/index.md) to open the Clone Row Form for each row
- In [Row Form Options](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md) we provide an implementation for the `setPrimaryKeyValue` function so we can attach a valid primary key to newly created rows
- Additionally we supply a `ROW_ADDED` [Observable Alert](https://www.adaptabletools.com/docs/handbook-alerting-observables/index.md) in [Alert Initial State](https://www.adaptabletools.com/docs/technical-reference-alerting/index.md) which triggers when the Row Form is created

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

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  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: 'Clone Row Form',
  actionColumnOptions: {
    actionColumns: [
      {
        columnId: 'clone',
        friendlyName: 'Clone',
        controls: [
          {
            type: 'command',
            command: 'clone',
            label: 'Clone',
            icon: {name: 'clone'},
          },
        ],
      },
    ],
  },
  rowFormOptions: {
    setPrimaryKeyValue: context => {
      return {
        ...context.rowData,
        id: context.adaptableApi.gridApi.getRowCount() + 1,
      };
    },
  },
  initialState: {
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'clone',
            'name',
            'github_stars',
            'update_stars',
            'week_issue_change',
            'update_issues',
            'github_watchers',
            'license',
            'language',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
    Alert: {
      AlertDefinitions: [
        {
          Name: 'alert-info-row-added',
          Rule: 'ROW_ADDED{}',
          MessageType: 'Info',
          Scope: {
            All: true,
          },
          AlertProperties: {
            DisplayNotification: false,
            HighlightRow: {
              BackColor: 'var(--ab-color-palette-28)',
              ForeColor: 'var(--ab-color-palette-14)',
            },
          },
        },
      ],
    },
  },
};
```

## Delete Row Form
The Delete Row Form is different to the others in that no visible Row Form is actually rendered.
However it is still useful as it fires the [Row Form Submitted Event](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md).
This allows developers to handle (or reject) the row deletion and provide any other actions.
**Example: Delete Row Form**

Triggers the Delete Row Form

- This demo triggers the Delete Row Form in AdapTable:
- We set a `Delete` Action Column Command - pinned to the right - in [Action Column Options](https://www.adaptabletools.com/docs/technical-reference-action-column/index.md) which forces the delete (but no visible Row Form appears)
- Additionally we supply a `ROW_REMOVED` [Observable Alert](https://www.adaptabletools.com/docs/handbook-alerting-observables/index.md) in [Alert Initial State](https://www.adaptabletools.com/docs/technical-reference-alerting/index.md) which triggers when the Row is deleted

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

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  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: 'Delete Row Form',
  actionColumnOptions: {
    actionColumns: [
      {
        columnId: 'delete',
        friendlyName: 'Delete',
        controls: [
          {
            type: 'command',
            command: 'delete',
            icon: {name: 'delete'},
          },
        ],
      },
    ],
  },
  initialState: {
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'github_stars',
            'update_stars',
            'week_issue_change',
            'update_issues',
            'github_watchers',
            'license',
            'language',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'delete',
          ],
          ColumnPinning: {
            delete: 'right',
          },
          AutoSizeColumns: true,
        },
      ],
    },
    Alert: {
      AlertDefinitions: [
        {
          Name: 'alert-info-row-removed',
          Rule: 'ROW_REMOVED{}',
          MessageType: 'Info',
          Scope: {
            All: true,
          },
          AlertProperties: {
            DisplayNotification: true,
          },
        },
      ],
    },
  },
};
```

## Row Form Contents
Row Forms are vertical and render a Label and relevant UI control for each Column in the AG Grid Row.
The Label displays the Column's Header and the field is an input type associated with the [Column's Data Type](https://www.adaptabletools.com/docs/dev-guide-aggrid-cell-data-types/index.md):
| Column Data Type | Input Type                                                                      |
| ---------------- | ------------------------------------------------------------------------------- |
| `text`           | Standard input                                                                  |
| `number`         | [Numeric Cell Editor](https://www.adaptabletools.com/docs/handbook-cell-editors-numeric/index.md) |
| `date`           | [Date Picker](https://www.adaptabletools.com/docs/handbook-cell-editors-date-picker/index.md)     |
| `boolean`        | Checkbox                                                                        |

- Read-only Columns display the field's value but no input is provided
- If a Column has been given a [Select Cell Editor](https://www.adaptabletools.com/docs/handbook-cell-editors-select/index.md), the Form displays it, populated with the Column's distinct values

## Customising Row Form Fields

Because a Row Form is a specialised [Adaptable Form](https://www.adaptabletools.com/docs/ui-tutorial-configuring-adaptable-forms/index.md), every [`AdaptableFormField`](https://www.adaptabletools.com/docs/reference/adaptableformfield.md) prop is available per column.

This includes: validation, presentation hints, conditional `hidden` / `disabled`, alternative field types (`textarea`, `radio`, `slider`, `time`, `datetime`, `color`), multi-select, and `fieldType: 'custom'` for bespoke widgets.

### `rowFormField`

Per-column override for the auto-built Form Field

  `(context: RowFormFieldContext) => Partial<AdaptableFormField> | undefined`

Receives a [`RowFormFieldContext`](https://www.adaptabletools.com/docs/reference/rowformfieldcontext.md) (the Column, and whether this is Create or Edit) and returns any subset of [`AdaptableFormField`](https://www.adaptabletools.com/docs/reference/adaptableformfield.md). Anything you omit falls back to the default derived from the Column's data type. Return `undefined` to keep the default Field.

```ts
rowFormOptions: {
  rowFormField: ({ column, type }) => {
    if (column.columnId === 'email') {
      return {
        required: true,
        pattern: '^\\S+@\\S+\\.\\S+$',
        helpText: 'used for delivery only',
      };
    }
    if (column.columnId === 'notes') {
      return { fieldType: 'textarea', rows: 4, placeholder: 'optional notes' };
    }
    if (column.columnId === 'priority') {
      return {
        fieldType: 'radio',
        options: [
          { label: 'Low',    value: 'low'    },
          { label: 'Normal', value: 'normal' },
          { label: 'High',   value: 'high'   },
        ],
      };
    }
    if (column.columnId === 'archived' && type === 'rowCreated') {
      return { hidden: true };  // never show on the Create form
    }
  },
}
```

- The `name` of the field is **always** the `columnId` - any `name` you return is ignored
- This is because renaming would desync the form's data from the underlying grid column

### `rowFormFieldLabel`

Custom Label for a Field in the Row Form

  `(context: RowFormFieldContext) => string`

Receives a [`RowFormFieldContext`](https://www.adaptabletools.com/docs/reference/rowformfieldcontext.md). Label-only override (superseded by `rowFormField`, which can return `label` and more). For anything beyond the label, use `rowFormField` instead.

```ts {3-7}
rowFormOptions: {
  rowFormFieldLabel: (context) => {
    return context.column.friendlyName === 'Language'
      ? `${context.column.friendlyName} (please select)`
      : context.column.friendlyName;
  },
},
```

- The standard **Save** button disables automatically while the form is invalid
- e.g. a `required` field is empty, or a `pattern` doesn't match

For full details of every property see the [Adaptable Form](https://www.adaptabletools.com/docs/ui-tutorial-configuring-adaptable-forms/index.md) tutorial

## Configuring Row Forms

Developers can configure Row Forms so they meet precise requirements and use cases. Options include:

- configuring the Form's title and description
- changing the buttons that appear (by default they are Cancel and Save)
- adding custom buttons
- providing a Primary Key value (useful when accessing the Create Row Form)
- disabling inline editing - so that all editing has to use the Form
  
  See [Configuring Row Forms](https://www.adaptabletools.com/docs/handbook-row-form-configuring/index.md) for more details
  

## Handling Row Form Submission

In the demos above, AdapTable performed all the row management automatically.

It created, edited or cloned the Row when the Form was submitted (and removed it when Delete is clicked).

This is perfectly suitable for most scenarios, and no additional developer / support input is required.

However, some use cases require that rows are only updated or deleted **after** the form has been submitted.

- This allows developers first to get details of the new / updated row and call any relevant backend services
- They can only then update the Grid's row data collection - typically via a round trip, rather than directly

For this reason, Adaptable provides the [Row Form Submitted Event](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md) which is fired:

- whenever a Row Form is submitted
- when a `Delete` Action Column Command Button is clicked

- If using this option then set `autoHandle` to _false_ in [Row Form Options](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md)
- This tells AdapTable not to do any row management itself but to leave it to the developer listening to the Event

### `autoHandle`

AdapTable will automatically handle all Grid changes

If this property is set to _false_, AdapTable will not directly update AG Grid when a Row Form is submitted.

Instead it will fire the [Row Form Submitted Event](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md) and the developer will react and do whatever is necessary.

```ts {3}
// Don't let AdapTable handle the form submission - do it ourself
rowFormOptions: {
  autoHandle: false,
},
```

### `onRowFormSubmit`

Called when a Row Form is submitted via a standard AdapTable button

  `(rowFormSubmittedInfo: RowFormSubmittedInfo) => void`

Receives a [`RowFormSubmittedInfo`](https://www.adaptabletools.com/docs/reference/rowformsubmittedinfo.md) (`rowCreated`, `rowEdited` or `rowDeleted`). Fires for the default Save / Delete flow (and together with the [Row Form Submitted Event](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md)). It is **not** called when you replace the buttons with `rowFormButtons` — those use each Button's `onClick` instead.

```ts {3-8}
rowFormOptions: {
  onRowFormSubmit: (rowFormSubmittedInfo) => {
    if (rowFormSubmittedInfo.type === 'rowEdited') {
      // persist, then update the Grid
    }
  },
},
```

**Example: Row Form Events**

Listening to the Row Form Submitted Event

- This demo provides a more advanced use case for leveraging Row Forms in Adaptable
- In [Row Form Options](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md) we set:
  - `autoHandle: false` so we handle submission ourselves (the default is _true_)
  - `setPrimaryKeyValue` so new rows get a valid primary key
- In [Action Column Options](https://www.adaptabletools.com/docs/technical-reference-action-column/index.md) we use `command` controls for `edit` and `clone` on one column and `delete` on a second (pinned columns in the demo layout)
- In [Dashboard Options](https://www.adaptabletools.com/docs/technical-reference-dashboard/index.md) we configure a Custom Button which when clicked opens the `Create` Row form
- Most importantly we listen to the [Row Form Submitted Event](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md) and based on the `type` of the action we perform the Row manipulation directly
- Note: in a more real world case you will likely call a server to do this but the key point is the separation of form submission and row-related action

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
  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 {
  AdaptableButton,
  AdaptableOptions,
  AlertMessageContext,
  CustomToolbarButtonContext,
  DashboardButtonContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Row Form Event',
  actionColumnOptions: {
    actionColumns: [
      {
        columnId: 'actions',
        friendlyName: 'Actions',
        controls: [
          {type: 'command', command: 'edit'},
          {type: 'command', command: 'clone'},
        ],
      },
      {
        columnId: 'delete',
        friendlyName: 'Delete',
        controls: [{type: 'command', command: 'delete'}],
      },
    ],
  },
  rowFormOptions: {
    autoHandle: false,
    setPrimaryKeyValue: context => {
      return {
        ...context.rowData,
        id: context.adaptableApi.gridApi.getRowCount() + 1,
      };
    },
  },
  dashboardOptions: {
    customDashboardButtons: [
      {
        label: 'Add New Row',
        onClick: (
          button: AdaptableButton<DashboardButtonContext>,
          context: DashboardButtonContext
        ) => {
          context.adaptableApi.rowFormApi.displayCreateRowForm();
        },
        buttonStyle: {
          variant: 'raised',
          tone: 'info',
        },
      },
    ],
    customToolbars: [
      {
        name: 'ButtonToolbar',
        title: 'Buttons',
        toolbarButtons: [
          {
            label: 'Add New Row',
            onClick: (
              button: AdaptableButton<CustomToolbarButtonContext>,
              context: CustomToolbarButtonContext
            ) => {
              context.adaptableApi.rowFormApi.displayCreateRowForm();
            },
            buttonStyle: {
              variant: 'raised',
              tone: 'info',
            },
          },
        ],
      },
    ],
  },
  initialState: {
    Dashboard: {
      Tabs: [
        {
          Name: 'Demo',
          Toolbars: ['ButtonToolbar', 'SystemStatus'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Alert', 'SystemStatus'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Alert: {
      AlertDefinitions: [
        {
          Name: 'alert-info-row-added',
          Rule: 'ROW_ADDED{}',
          MessageType: 'Info',
          Scope: {
            All: true,
          },
          AlertProperties: {
            DisplayNotification: false,
            HighlightRow: {
              BackColor: 'var(--ab-color-palette-28)',
              ForeColor: 'var(--ab-color-palette-14)',
            },
          },
        },
        {
          Name: 'alert-error-row-removed',
          Rule: 'ROW_REMOVED{}',
          AlertProperties: {
            DisplayNotification: true,
          },
          MessageType: 'Error',
          //  MessageText: 'A Row was Deleted',
          Scope: {
            All: true,
          },
        },
      ],
    },
    FlashingCell: {
      FlashingCellDefinitions: [
        {
          Name: 'Flashing_RowAny_Change',
          Scope: {
            All: true,
          },
          Rule: 'ANY_CHANGE()',
          FlashTarget: 'row',
          FlashDuration: 2000,
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'actions',
            'name',
            'github_stars',
            'update_stars',
            'week_issue_change',
            'update_issues',
            'github_watchers',
            'license',
            'language',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'delete',
          ],
          ColumnPinning: {
            actions: 'left',
            delete: 'right',
          },
          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',
    sortable: true,
  },
  {
    field: 'language',
    cellDataType: 'text',
    enablePivot: true,
    enableRowGroup: true,
  },
  {
    field: 'github_stars',
    headerName: 'GitHub Stars',
    cellDataType: 'number',
    enableValue: true,
  },
  {
    field: 'license',
    cellDataType: 'text',
    editable: false,
  },
  {
    field: 'created_at',
    headerName: 'Created',
    cellDataType: 'date',
  },
  {
    field: 'has_wiki',
    headerName: 'Has Wiki',
    cellDataType: 'boolean',
    enablePivot: true,
    enableRowGroup: true,
  },
  {
    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: 'open_issues_count',
    headerName: 'Open Issues',
    cellDataType: 'number',
    enableValue: true,
  },
  {
    field: 'closed_issues_count',
    headerName: 'Closed Issues',
    cellDataType: 'number',
    enableValue: true,
  },
  {
    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: 'week_issue_change',
    headerName: 'Issue Change',
    cellDataType: 'number',
    enableValue: true,
  },
];
```

**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo} from '@adaptabletools/adaptable';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  adaptableApi.eventApi.on('RowFormSubmitted', event => {
    if (event.type === 'rowEdited') {
      const {rowNode, formData} = event;
      const newRowData = {
        ...rowNode.data,
        ...formData,
      };
      adaptableApi.gridApi.updateGridData([newRowData]);
      adaptableApi.systemStatusApi.setSuccessSystemStatus('Row Updated in Api');
    }
    if (event.type === 'rowDeleted') {
      const {rowNode} = event;
      const deletedRowData = rowNode.data;
      adaptableApi.gridApi.deleteGridData([deletedRowData]);
      adaptableApi.systemStatusApi.setErrorSystemStatus('Row Deleted in Api');
    }
    if (event.type === 'rowCreated') {
      const {formData} = event;
      // postProcess data
      const count = adaptableApi.gridApi.getRowCount() + 1;
      const newRowData = {...formData, id: count};
      adaptableApi.gridApi.addGridData([newRowData], {addIndex: 0});
      adaptableApi.systemStatusApi.setInfoSystemStatus('Row Created in Api');
    }
  });
};
```

<RelatedBlogCard path="/blog/2026-08-03-row-forms-in-adaptable" />

### FAQ

**How can I check data provided in the form before it enters the AG Grid?**
First, ensure that `autoHandle` is set to _false_ to prevent automatic entry; then listen to the [Row Form Submitted Event](https://www.adaptabletools.com/docs/technical-reference-row-form/index.md) to perform any updates yourself

**Should I use Action Column Commands or `rowFormApi`?**
Use **commands** for per-row CRUD in the grid; use **`rowFormApi`** (or a dashboard button) for **Create** and any flow that is not tied to a row's Action Column.

**What is the default for `autoHandle`?**
**`true`** — AdapTable updates AG Grid on Save unless you set `autoHandle` to _false_ (or replace the default buttons with `rowFormButtons` and handle clicks yourself).
