Summary
HOWTO configure percentage fieldsQuestion/Problem Description
In update.CRM web all percentage fields are displayed with a slider (plus adjacent number input). The widget used for displaying the slider is called u8.Base.Widgets.RangeInput . The corresponding FieldWidgetFactory entry is PercentField .This article describes how to change the displayed range and other useful options.
Environment
AureaCRM 8.x and 9.xResolution
Default options for the widget
Per default all percentage fields show a slider from 0 to 100 % with a snap based on the available digits after the comma and a pagesize of 10%.Note: we do not take information from the data model into account to generate these values. i.e. setting the negative values flag for a field will not make the slider display a different range. If you want negative values displayed, you need to change the min value as described in the section below.
HOWTO Change options
To change slider options, you can provide the FieldWidgetFactory entry with additional options for the widget via the Widget attribute of the field in a Field Control.The available options are:
option name | description | default value |
---|---|---|
min | the minimum selectable value | 0 |
max | the maximum selectable value | 100 |
snap | the minimum step size when using the slider, e.g. when snap is 5 and the current value is 10% and you move the slider to the right, the next value is 15% | 5 |
decimalDigits | The widget will automatically round to the precision given by this option. | as defined by the fieldschema in the datamodel |
pageSize | the value change when using page-up and page-down on your keyboard | (max - min)/10 |
Example
If you enter the following code into the Widget attribute of a percentage field, the resulting widget will display a slider that allows you to select values from -50% to 200% in steps of 5%.
{
factory: "PercentField",
options:
{
min: -50,
max: 200,
snap: 5
}
}
HOWTO disable a percentage field
If you do not want to display a slider at all and are satisfied with a plain text field, you can just enter TextField in the Widget attribute of the field in a field control.A good place to turn it off would be an unlimited percentage field (like "Weighting" in Questions of a Questionnaire).