Shortcuts
Summary
- Shortcuts ensure that numeric data is edited accurately and quickly in AG Grid
- They allow users to avoid "fat finger" issues when editing data quickly
- They consist of 4 main elements:
- Which Columns can accept the Shortcut
- What key will apply the Shortcut
- What Operation will be applied when the Key is pressed
- What Value will be applied
- This allows users to provide a Shortcut where clicking 'M' in a Price column will multiply by 1000
Shortcuts ensure that numeric data is edited accurately and quickly in AG Grid.
Each Shortcut consists of an alphabet keystroke which, when entered into a numeric cell editor, applies a mathematical operation using the existing cell contents.
Note
A Shortcut can be limited to specific Layouts via Layout Extensions
- Two Shortcuts in Initial State (see
adaptableOptions.ts):Kon all numeric columns — multiply by 1,000Pongithub_stars— add 1
- Double-click a numeric cell, start editing, and type
Kto multiply by 1,000 - Double-click
github_stars, start editing, and typePto add 1
Applying Shortcuts
Shortcuts are applied by pressing the key identified as the ShortcutKey in a Shortcut in a numeric cell editor.
AdapTable will check if the key press is a valid Shortcut and, if it is, perform the mathematical calculation.
For example, a Shortcut of k with an operation of Multiply by 1000 would convert an initial cell value of 5 into 5,000 if the k key is pressed on the keyboard.
Creating Shortcuts
Shortcuts can be managed at runtime via the Shortcut section of the Settings Panel.
This lists the details of all existing Shortcuts in Adaptable State together with options to:
- create (via the Shortcut Wizard)
- edit (via the Shortcut Wizard)
- delete
- suspend
- share (if Team Sharing is running)
UI Step by Step Guide
Using the Shortcut Wizard
Shortcuts with an Entitlement of ReadOnly can be applied but Users cannot manage or suspend them.
Configuring Shortcuts
Shortcuts can be provided at design-time through Shortcut Initial Adaptable State.
Developer Guide
Providing Shortcuts in Initial Adaptable State
const initialState: InitialState = {
Shortcut: {
Shortcuts: [
{
Name: 'Shortcut-K-1',
Scope: { DataTypes: ['number'] },
ShortcutKey: 'K',
ShortcutOperation: 'Multiply',
ShortcutValue: 1000,
},
{
Name: 'Shortcut-P-1',
Scope: { ColumnIds: ['github_stars'] },
ShortcutKey: 'P',
ShortcutOperation: 'Add',
ShortcutValue: 1,
},
],
},
};Choose a unique Name for each entry in Shortcut.Shortcuts.
Specify which numeric columns can use the Shortcut, or set DataTypes: ['number'] to include all numeric columns.
Find Out More
See Guide to Column Scope for more on this commonly used object
Set ShortcutKey — the letter entered in the cell editor to trigger the Shortcut.
Caution
The key must be a letter of the alphabet.
Set ShortcutOperation to Add, Subtract, Multiply, or Divide.
Set ShortcutValue — the numeric operand used with the current cell value and the operation.
Caution
This property must be numeric.
Shortcuts in Row Forms
Row Forms are dynamically-created by AdapTable, designed for safe, controlled AG Grid data editing.
Any defined Shortcuts will also be operative in the numeric input in the Row Form.
- This demo has a Shortcut defined for
numericcolumns - multiply by 1 Million when M is clicked - An
EditAction Column command opens an Edit Row Form; the same Shortcut works in that form
- Click Edit on a row to open the form
- In a numeric field, type
Mand note how the value is multiplied by 1,000,000
FAQ
Can we apply shortcuts on non-numeric columns? No, Shortcuts only work for numeric columns.
Can we apply shortcuts on multiple columns simultaneously? No, Shortcuts work by intercepting a cell edit and only one cell in AG Grid can be edited at a time. Use Smart Edit or Bulk Update to update multiple cells.
Can I use Shortcut to bypass Data Validation? No, Shortcuts will not be allowed by AdapTable if the result breaks a Data Validation Rule.
Do Shortcuts operate in Row Forms? Yes you can use Shortcuts while editing data using a Row Form