Percentage Cell Editor
Summary
- The Percentage Cell Editor allows cells where the value is a percentage to be edited as such
- This works in the same fashion as when editing percentages in Excel
The Percentage Cell Editor allows cells, where the value is a percentage, to also be edited as percentages.
The Editor is designed to work in exactly the same way as percentage editors in Excel.
Note
There is a parallel AdaptableReactPercentageEditor available for use in AdapTable React
For example a value of 0.123456 will be displayed in the Percentage Cell Editor as 12.3456%.
Hint
- Columns that use the Percentage Cell Editor are typically also given a Number Display Format of Percentage
- This ensures that the Display Value and the Cell Editor Value remain consistent
- This demo shows how to use the Percentage Cell Editor on a
usagecolumn (stored values such as0.12345,0.13579) - In
columnDefs.ts, the column usescellEditor: AdaptablePercentageEditor - In
adaptableOptions.ts, Initial State defines a percentage Number Display Format forusage(multiplier 100,%suffix)
- Try to edit a cell in the
UsageColumn and see that the Percentage Editor is used - Suspend the Format Column to see the real underlying value for the
Usagecolumn
Cell Editor Params
Similar to the Numeric Cell Editor, the Percentage Editor is configurable.
This is done using the cellEditorParams property in the AG Grid Column Definition.
This maps to the AdaptablePercentageCellEditorParams object, which contains 2 properties:
showClearButton- whether to show the Clear button (defaults to true)
Note
When set to true, this property works together with emptyValue
emptyValue- value to set for the cell when the Clear button is clicked (defaults to an empty string)
Caution
If the colDef has a valueParser provided as a function, that will be used before setting the value for the cell
- Same Percentage Cell Editor and Display Format as the demo above, with
cellEditorParamson theusagecolumn incolumnDefs.ts:showClearButtonis set to true so we see a Clear ButtonemptyValuehas been set to1(instead of the default empty string; shown in the editor as 1%)
- Try to edit a cell in the
UsageColumn and see that the Percentage Editor is used - Note that there is now a
Clearbutton, and when it is clicked the value changes to 1%