Plus Minus
Summary
- Plus / Minus increments / decrements numeric cells when the
+or-keys are pressed - Users can set the amount by which the Cell will change
- And specify a Nudge Rule which defines whether the Nudge should be applied
Plus / Minus updates editable, numeric cells quickly and safely in response to a single keyboard input:
Note
This is ideal for situations where data needs to be edited incredibly quickly (e.g. if marking to market)
- the
+keyboard key will cause an increment of the cell's value - the
-keyboard key will cause a decrement of the cell's value
Hint
It is possible to configure different keyboard keys that will trigger the Nudge (see below)
Plus Minus uses Nudge Rules - provided by users - which specify:
- where to apply the Nudge
- the amount by which to increment or decrement the cell
- when to apply the Nudge - by providing an optional Rule
Caution
- Ensure that the
CellSelectionModulehas been provided in AG Grid Modules - Additionally make sure that the
cellSelectionproperty in AG Grid GridOptions is not set to false or null
Note
A Plus Minus Nudge can be limited to specific Layouts via Layout Extensions
Applying Plus Minus
Plus / Minus is applied when the user presses the + or - keys in numeric cells which are in a Nudge Rule scope.
AdapTable will automatically increment or decrement the cell by the Rule's Nudge Value.
- This demo has 2 Plus / Minus Rules defined
- Nudges in the
GitHub Starscolumn change the value by 100 - Nudges in the
GitHub Watcherscolumn change the value by 200
- Nudges in the
- Select a cell in the
github_starsorgithub_watcherscolumn and press+or-
Plus Minus Rules
It is possible to add a Rule to a Plus / Minus Definition.
Note
The Rule is a standard Boolean Expression evaluated by AdapTableQL
This sets that the Plus / Minus is only applied by AdapTable if the Rule is evaluated as true.
Hint
- It is also possible to set 2 (or more) Nudge Definitions one with a Rule, and another without a Rule
- The default Nudge Definition will be applied only if all Rules have been evaluated and returned false
- This demo has 3 Plus / Minus Rules defined, all for the
GitHub Starscolumn:- Nudge by 500 if the value for the
Languagecolumn in the Row is TypeScript - Nudge by 250 if the value for the
Languagecolumn in the Row is HTML - Nudge by 10 in all other cases (the default value - when no Rule is applied)
- Nudge by 500 if the value for the
- Select a cell in the
github_starscolumn and press+or- - If
languageis TypeScript it nudges by 500; if HTML by 250; otherwise by 10
Custom Plus Minus Keys
By default Plus Minus Nudges are triggered when the user clicks "+" or "-" keys in the keyboard.
However its possible to override these default keys and specify different trigger keys.
This can be provided in 2 ways:
| Scope | Configuration |
|---|---|
| Global | Using incrementKey and decrementKey props in plusMinusOptions (in Edit Options) |
| Per Nudge | Configuring specific IncrementKey and DecrementKey values on the Plus Minus object |
Hint
It is also possible to provide combinations of key strokes e.g Ctrl + I or Shift, Alt + D
The order of evaluation, when checking whether a Nudge Rule has been invoked, is:
- first, any specific keys provided in a Nudge Rule
- next any bespoke global PlusMinusOptions values provided at design time
- finally the default AdapTable Options values specified by AdapTable
Note
- This allows you to provide 2 Plus Minus Nudges for all columns (without needing to specify a Rule)
- For instance you configure "x" and "y" to increment all numeric columns by 10 and 20 respectively
- In this example we have changed the defaults keys to increment and decrement in 3 ways:
- We globally set default keys of
uanddin Plus Minus Options — nudgegithub_watchers - Per-nudge keys
fandjon thegithub_starsrule - Per-nudge keys
ctrl+Iandctrl+Don theweek_issue_changerule
- We globally set default keys of
- Type
uordingithub_watchersand see the cell value change - Type
forjingithub_starsand see the cell value change - Type
Ctrl+IorCtrl+Dinweek_issue_changeand see the cell value change
Keyboard Shortcut Combinations
Trigger keys are not limited to single characters: both the global incrementKey / decrementKey and the per-Nudge IncrementKey / DecrementKey also accept keyboard shortcut combinations.
A combination uses + as the glue between its parts, for example shift+Enter or ctrl+ArrowDown. The supported modifiers are:
| Modifier | Token |
|---|---|
| Control | ctrl |
| Command | cmd |
| Alt | alt |
| Shift | shift |
Hint
- The default single keys (
+and-) continue to work exactly as before - A single character is always treated as a literal key, never as a combination
Caution
Because + is the glue between parts, it cannot itself be combined with modifiers (use it as a standalone key)
- In this example the trigger keys are keyboard shortcut combinations rather than single characters:
- We globally set
shift+Enter/shift+Backspacein Plus Minus Options — nudgegithub_watchers - Per-nudge
ctrl+ArrowUp/ctrl+ArrowDownongithub_stars
- We globally set
- Select a cell in
github_watchersand pressShift+EnterorShift+Backspace - Select a cell in
github_starsand pressCtrl+ArrowUporCtrl+ArrowDown
Creating Plus Minus Nudges
Plus / Minus Nudges can be managed at runtime via the Plus / Minus section of the Settings Panel.
This lists the details of all existing Nudge Rules in Adaptable State together with options to:
- create (via the Plus / Minus Wizard)
- edit (via the Plus / Minus Wizard)
- delete
- suspend
- share (if Team Sharing is running)
UI Step by Step Guide
Using the Plus / Minus Wizard
Defining Plus Minus Nudges
Plus / Minus Nudges can be provided at design-time through Plus Minus Initial Adaptable State with the following steps:
Developer Guide
Providing Plus Minus Nudges in Initial State
// Three Plus Minus nudges on Web Frameworks columns
const initialState: InitialState = {
PlusMinus: {
PlusMinusNudges: [
{
Name: 'stars-watchers-100',
Scope: { ColumnIds: ['github_stars', 'github_watchers'] },
NudgeValue: 100,
},
{
Name: 'stars-typescript-500',
Scope: { ColumnIds: ['github_stars'] },
Rule: '[language]="TypeScript"',
NudgeValue: 500,
},
{
Name: 'stars-watchers-30-xy',
Scope: { ColumnIds: ['github_stars', 'github_watchers'] },
NudgeValue: 30,
IncrementKey: 'x',
DecrementKey: 'y',
},
],
},
};Each nudge has a unique Name in PlusMinus.PlusMinusNudges.
Specify which numeric columns can use the Nudge Rule, or set Number DataType to include all numeric columns.
Set NudgeValue — the amount by which the cell increments or decrements when the trigger keys are pressed.
Optional Boolean Rule (AdapTableQL). The nudge applies only when the rule evaluates to true.
Optional IncrementKey / DecrementKey override the default + / - (or global keys from Plus Minus Options).
UI Entitlements
Plus / Minus Nudge Rules with ReadOnly Entitlement can be applied but Users cannot manage or suspend them.
FAQ
Can I use Plus/Minus across multiple cells simultaneously? Yes, AdapTable will automatically apply the correct nudge value for each cell in the selection.
AdapTable Resources
- Data Entry
- Editing Technical Reference
- Layout Extensions
- AG Grid Modules (
CellSelectionModule)