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 us 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
- We have added a new column called
Usagewhich has values like 0.12345, 0.13579 etc. - In ColumnDefs we set the
CellEditorfor the column to be theAdaptablePercentageEditor - We also created a Number Display Format for the
UsageColumn of Percentage
Open to see how the Percentage Cell Editor is set up
- 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 withemptyValue -
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
- This demo contains the same Percentage Cell Editor (and Display Format) as the demo above but with 2 Cell Editor Params set:
showClearButtonis set to true so we see a Clear ButtonemptyValuehas been set to 1 (instead of default of 0)
Open to see how the Percentage Cell Editor is set up
- 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%