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
Applying Plus Minus
Plus / Minus is applied when the user presses the + or - keys in numeric cells which are in a Nude 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 the
GitHub StarsorGithub WatchersColumns and press the+or-key on your Keyboard
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 evalated 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 the
GitHub Starscolumn and press the+or-key on your Keyboard - If
Languagecolumn in the Row is TypeScript it will nudge by 500; otherwise it will nude 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 |
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
Hint
- 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 2 ways:
- We globally set default keys of 'u' and 'd' in Plus Minus Options - we see this work if we nudge
Github Watcherscolumn - We specificialy override these with bespoke keys of 'f' and 'j' - which we apply to the Nudge Rule in the
Github Starscolumn
- We globally set default keys of 'u' and 'd' in Plus Minus Options - we see this work if we nudge
- Type 'u' or 'd' in
Github Watcherscolumn and see the cell value change - Type 'f' or 'j' in
Github Starscolumn and 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. - Because
+is the glue between parts, it cannot itself be combined with modifiers (use it as a standalone key instead).
- In this example the trigger keys are keyboard shortcut combinations rather than single characters:
- We globally set
shift+Enter/shift+Backspacein Plus Minus Options - we see this work if we nudge theGithub Watcherscolumn - We override these per-Nudge with
ctrl+ArrowUp/ctrl+ArrowDown- which we apply to theGithub Starscolumn
- We globally set
- Select a cell in the
Github Watcherscolumn and pressShift+EnterorShift+Backspaceto change the value - Select a cell in the
Github Starscolumn and pressCtrl+ArrowUporCtrl+ArrowDownto change the value
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 Shortcut Wizard)
- edit (via the Shortcut 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:
// Set 3 Plus Minus Rules
// Bid & Ask columns to nudge by 10 on any key press (using default keyboard keys)
// Bid & Ask columns to nudge by 30 when x or y keys are pressed
// Bid column - but only when Currency is Euro
const initialState: InitialState = {
PlusMinus: {
PlusMinusNudges: [
{
Name: 'bid-ask-10',
Scope: { ColumnIds: ['bid', 'ask'] },
NudgeValue: 10,
},
{
Name: 'bid-eur-20',
Scope: { ColumnIds: ['bid'] },
Rule: { BooleanExpression: '[currency]="EUR"'},
NudgeValue: 20,
},
{
Name: 'bid-ask-30',
Scope: { ColumnIds: ['bid', 'ask'] },
NudgeValue: 30,
IncrementKey: 'x',
DecrementKey: 'y',
},
],
},
};Provide a unique and identifiable name for the Nudge Rule.
Specify which numeric columns can use the Nudge Rule.
Or set Number DataType to include all numeric columns.
Set the numeric value for the Nudge Rule - the amount by which the cell will increment / decrement in response to key press.
Provide an optional Boolean Expression (which will be evaluated by AdapTableQL) specifying when Nudge Value should be applied.
Provide custom Keyboard keys to override those provided by AdapTable - either single keys or keyboard shortcut combinations (e.g. shift+Enter, ctrl+ArrowUp).
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.