Action Column Forms

View as Markdown

Summary

  • A form Control opens an Adaptable Form in a popover
  • It is the same Form used in Alerts, Export Destinations, Data Sets and Custom Toolbars
  • getInitialData seeds the fields from the row
  • Form buttons receive context.formData plus the Action Column context

A form Control is for editing a few related fields without leaving the grid — counts, a status change, a short comment.

The form property is a standard AdaptableForm — the same object used for Alert messages, Custom Export Destinations, Data Sets and Custom Toolbar forms. See Adaptable Forms for full details on titles, fields, validation and buttons.

Use getInitialData to seed those fields from the row. Form buttons receive context.formData plus the Action Column context, so they can write back to the row.

Developer Guide

Defining a Form Control

actionColumnOptions: {
  actionColumns: [
    {
      columnId: 'edit_counts',
      friendlyName: 'Counts',
      controls: [
        {
          type: 'form',
          label: 'Edit',
          icon: {name: 'edit'},
          getInitialData: (context) => ({
            open_issues_count: context.data.open_issues_count,
            closed_issues_count: context.data.closed_issues_count,
            open_pr_count: context.data.open_pr_count,
            closed_pr_count: context.data.closed_pr_count,
          }),
          form: {
            title: 'Edit counts',
            fields: [
              {name: 'open_issues_count', label: 'Open Issues', fieldType: 'number'},
              {name: 'closed_issues_count', label: 'Closed Issues', fieldType: 'number'},
              {name: 'open_pr_count', label: 'Open PRs', fieldType: 'number'},
              {name: 'closed_pr_count', label: 'Closed PRs', fieldType: 'number'},
            ],
            buttons: [
              {
                label: 'Save',
                onClick: (_button, context) => {
                  [
                    'open_issues_count',
                    'closed_issues_count',
                    'open_pr_count',
                    'closed_pr_count',
                  ].forEach((field) => {
                    context.rowNode.setDataValue(
                      field,
                      Number(context.formData[field])
                    );
                  });
                },
              },
            ],
          },
        },
      ],
    },
  ],
},
1
Add Action Column Options

Put the Column in actionColumnOptions.actionColumns.

2
Identify the Column

Supply columnId and an optional friendlyName.

3
Set the Control type

Set type to 'form'. label and icon become the trigger that opens the popover.

4
Seed the Form

getInitialData copies values from the current row into the Form fields.

5
Define the fields

form.fields is a standard AdaptableForm field list.

6
Handle Save

Form buttons receive context.formData and can write back to the row.

Action Columns: Form
Fork
  • Counts opens a Form seeded from Open / Closed Issues and Open / Closed PRs
  • Save writes the four values back to the row
Loading demo…