Plus Minus

View as Markdown

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 CellSelectionModule has been provided in AG Grid Modules
  • Additionally make sure that the cellSelection property 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.

Using Plus/Minus
Fork
  • This demo has 2 Plus / Minus Rules defined
    • Nudges in the GitHub Stars column change the value by 100
    • Nudges in the GitHub Watchers column change the value by 200
Try It Out
  • Select a cell in the github_stars or github_watchers column and press + or -
Loading demo…

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
Using Plus/Minus Rules
Fork
  • This demo has 3 Plus / Minus Rules defined, all for the GitHub Stars column:
    • Nudge by 500 if the value for the Language column in the Row is TypeScript
    • Nudge by 250 if the value for the Language column in the Row is HTML
    • Nudge by 10 in all other cases (the default value - when no Rule is applied)
Try It Out
  • Select a cell in the github_stars column and press + or -
  • If language is TypeScript it nudges by 500; if HTML by 250; otherwise by 10
Loading demo…

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:

ScopeConfiguration
GlobalUsing incrementKey and decrementKey props in plusMinusOptions (in Edit Options)
Per NudgeConfiguring 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
Custom Plus/Minus Keys
Fork
  • In this example we have changed the defaults keys to increment and decrement in 3 ways:
    • We globally set default keys of u and d in Plus Minus Options — nudge github_watchers
    • Per-nudge keys f and j on the github_stars rule
    • Per-nudge keys ctrl+I and ctrl+D on the week_issue_change rule
Try It Out
  • Type u or d in github_watchers and see the cell value change
  • Type f or j in github_stars and see the cell value change
  • Type Ctrl+I or Ctrl+D in week_issue_change and see the cell value change
Loading demo…

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:

ModifierToken
Controlctrl
Commandcmd
Altalt
Shiftshift

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)

Plus/Minus Key Combinations
Fork
  • In this example the trigger keys are keyboard shortcut combinations rather than single characters:
    • We globally set shift+Enter / shift+Backspace in Plus Minus Options — nudge github_watchers
    • Per-nudge ctrl+ArrowUp / ctrl+ArrowDown on github_stars
Try It Out
  • Select a cell in github_watchers and press Shift+Enter or Shift+Backspace
  • Select a cell in github_stars and press Ctrl+ArrowUp or Ctrl+ArrowDown
Loading demo…

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',
      },
    ],
  },
};
1
Give the Nudge a Name

Each nudge has a unique Name in PlusMinus.PlusMinusNudges.

2
Select Plus / Minus Scope

Specify which numeric columns can use the Nudge Rule, or set Number DataType to include all numeric columns.

3
Specify the Nudge Value

Set NudgeValue — the amount by which the cell increments or decrements when the trigger keys are pressed.

4
Provide an Expression (optional)

Optional Boolean Rule (AdapTableQL). The nudge applies only when the rule evaluates to true.

5
Specify Custom Keyboard Keys (optional)

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