PercentColumn

A column that either displays a basic percent number, a rectangular progress bar, or a circular progress bar.

Percent column
//<code-header>
fiddle.title = 'Percent column';
//</code-header>
// grid with PercentColumn
const grid = new Grid({
    appendTo   : targetElement,
    // makes grid as high as it needs to be to fit rows
    autoHeight : true,
    features   : { sort : 'percent' },
    data       : [
        { id : 1, name : 'Set up Confluence', percent : 25 },
        { id : 2, name : 'Figma design', percent : 50 },
        { id : 3, name : 'Safari UI tweaks', percent : 75 },
        { id : 4, name : 'Responsive rendering', percent : 100 },
        { id : 5, name : 'RTL support', percent : 125 }
    ],
    columns : [
        { field : 'name', text : 'Name', flex : 1 },
        {
            type          : 'percent',
            field         : 'percent',
            mode          : 'bar',
            text          : 'Bar shape',
            flex          : 1,
            headerWidgets : [
                {
                    type  : 'slidetoggle',
                    text  : 'Show value',
                    style : 'margin-inline-start: auto',
                    async onChange({ checked }) {
                        this.owner.showValue = checked;
                    }
                }
            ]
        },
        {
            type  : 'percent',
            field : 'percent',
            text  : 'Circle',
            mode  : 'circle',
            width : 100,
            align : 'center'
        },
        { type : 'percent', field : 'percent', text : 'As text', mode : 'number', width : 100 }
    ]
});

new Grid({
    appendTo : document.body,

    columns : [
        { type: 'percent', text: 'Progress', data: 'progress' }
    ]
});

Styling

All cells in this column get a b-percent-cell class added.

If mode is set to bar (default), the progress bar element in the cell gets a few special CSS classes added:

  • If value equals 0, a b-zero CSS class is added to the circle element.
  • If value is less than lowThreshold, a b-low CSS class is added to the bar element.
  • If value equals 100, a b-full CSS class is added to the bar element.
  • If value is > 100, a b-over CSS class is added to the bar element.

If mode is set to circle, the progress circle element in the cell gets a few special CSS classes added:

  • If value equals 0, a b-empty CSS class is added to the circle element.
  • If value equals 100, a b-full CSS class is added to the circle element.
  • If value is > 100, a b-over CSS class is added to the circle element.

Default editor is a NumberField.

Configs

89

Common

autoWidthColumn
fieldColumn
fitModeColumn
flexColumn
largeStepNumberColumn
listenersEvents
maxNumberColumn
maxWidthColumn
minNumberColumn
stepNumberColumn
textColumn
unitNumberColumn
widthColumn

Rendering

When below this percentage the bar will have b-low CSS class added. By default, it turns the bar red.

mode: number | bar | circle= barAlso a property

This mode controls the rendering.

  • number to render a formatted number value (e.g. 15%)
  • circle to render a circular progress bar
  • bar to render a plain rectangular progress bar
showValue: Boolean= falseAlso a property

Set to true to render the number value inside the bar, for example '15%'.

cellClsColumn
clsColumn
iconColumn
rendererNumberColumn
tooltipColumn

Accessibility

ariaLabelColumn

Export

Integration

vueColumn

Interaction

collapsedColumn
draggableColumn
editorColumn
groupableColumn
hideableColumn
resizableColumn
sealedColumn
sortableColumn

Layout

alignNumberColumn
hiddenColumn
lockedColumn
minWidthColumn
regionColumn

Menu

Merge cells

mergeableColumn

Misc

localeClassLocalizable
localizableLocalizable
tagsColumn
treeColumn

Other

formatNumberColumn
formulaColumn
pinnedColumn
readOnlyColumn

Summary

sumColumn
summariesColumn

Properties

160

Common

autoWidthColumn
fieldColumn
fitModeColumn
flexColumn
largeStepNumberColumn
maxNumberColumn
maxWidthColumn
minNumberColumn
stepNumberColumn
textColumn
unitNumberColumn
widthColumn

Class hierarchy

isPercentColumn: Boolean= truereadonly
Identifies an object as an instance of PercentColumn class, or subclass thereof.
isPercentColumn: Boolean= truereadonlystatic
Identifies an object as an instance of PercentColumn class, or subclass thereof.
isColumnColumn
isEventsEvents
isLocalizableLocalizable
isModelModel
isModelLinkModelLink
isModelStmModelStm
isNumberColumnNumberColumn
isTreeNodeTreeNode

Rendering

When below this percentage the bar will have b-low CSS class added. By default, it turns the bar red.

mode: number | bar | circle= barAlso a config

This mode controls the rendering.

  • number to render a formatted number value (e.g. 15%)
  • circle to render a circular progress bar
  • bar to render a plain rectangular progress bar
showValue: Boolean= falseAlso a config

Set to true to render the number value inside the bar, for example '15%'.

cellClsColumn
clsColumn
iconColumn
rendererNumberColumn
tooltipColumn

Accessibility

ariaLabelColumn

Editing

copyOfModel
isValidModel

Export

Fields

allFieldsstaticModel
autoExposeFieldsstaticModel
childrenFieldstaticModel
fieldMapstaticModel
fieldsstaticModel
idFieldstaticModel

Grouping

Identification

keyModel

Integration

vueColumn

Interaction

collapsedColumn
draggableColumn
editorColumn
groupableColumn
hideableColumn
resizableColumn
sealedColumn
sortableColumn

JSON

jsonModel

Layout

alignNumberColumn
hiddenColumn
lockedColumn
minWidthColumn
regionColumn

Lifecycle

configBase

Linked records

hasLinksModelLink
isLinkedModelLink
recordLinksModelLink

Menu

Merge cells

mergeableColumn

Misc

localeHelperLocalizable
localeManagerLocalizable
stmModelStm
tagsColumn
treeColumn

Other

$namestaticModel
defaultsColumn
elementColumn
formatNumberColumn
formulaColumn
gridColumn
pinnedColumn
readOnlyColumn
relationsstaticModel
subGridColumn
typestaticColumn
visibleColumn

Parent & children

allChildrenTreeNode
childLevelTreeNode
firstChildTreeNode
isLeafTreeNode
isLoadedTreeNode
isParentTreeNode
isRootTreeNode
lastChildTreeNode
nextSiblingTreeNode
parentTreeNode
parentIdTreeNode

Summary

sumColumn
summariesColumn

Functions

77

Other

Renderer that displays a progress bar in the cell. If you create a custom renderer, and want to include the default markup you can call defaultRenderer from it.

new Grid({
    columns: [
        {
            type: 'percent',
            text : 'Percent',
            field : 'percent',
            renderer({ value }) {
                const domConfig = this.defaultRenderer();

                if (value > 100) {
                    domConfig.className = b-percent-bar-outer over-allocated';
                }

                return domConfig;
            }
        }
    ]
}
ParameterTypeDescription
rendererDataObject

The data object passed to the renderer

rendererData.valueNumber

The value to display

Returns: DomConfig -

DomConfig object representing the default markup for the cells content

hideColumn
LstaticLocalizable
onEvents
relayAllEvents
showColumn
toggleColumn
triggerEvents
unEvents

Configuration

applyDefaultsstaticBase

Editing

copyModel
getDataModel
removeModel
setModel

Events

Fields

addFieldstaticModel
getModel
processFieldstaticModel
removeFieldstaticModel

Identification

asIdstaticModel

JSON

toJSONModel

Lifecycle

destroystaticBase

Misc

equalsModel
initClassstaticBase
isOfTypeNamestaticBase
linkModelLink
mixinstaticBase
optionalLstaticLocalizable

Parent & children

appendChildTreeNode
bubbleTreeNode
bubbleWhileTreeNode
containsTreeNode
isExpandedTreeNode
removeChildTreeNode
traverseTreeNode

Events

5

Event handlers

5

Typedefs

2

CSS variables

16
NameDescription
--b-percent-column-bar-border-radiusBarPercent bar border radius
--b-percent-column-bar-max-heightBarPercent bar max height
--b-percent-column-bar-borderBarPercent bar border
--b-percent-column-circle-thicknessCircleThickness of the outer circle in "circle" mode
--b-percent-column-circle-label-font-sizeCircleLabel font size in "circle" mode
--b-percent-column-bar-backgroundBarPercent bar background color (the "empty" part of the bar)
--b-percent-column-low-fill-backgroundBarFill color for the bar when value is below `lowThreshold`
--b-percent-column-wide-value-colorBarValue label's color when the bar is wide, and label gets moved inside the bar
--b-percent-column-low-value-colorBarValue label's color when the value is below `lowThreshold`
--b-percent-column-zero-value-colorBarValue label's color when the value is zero
--b-percent-column-circle-backgroundCircleBackground color for the circle in "circle" mode
--b-percent-column-circle-label-colorCircleValue label's color in "circle" mode
--b-percent-column-fill-backgroundBarFill color for the bar (the "filled" part of the bar)
--b-percent-column-value-colorValue label's color
--b-percent-column-circle-done-colorCircleColor of the filled part of the circle in "circle" mode
--b-percent-column-circle-label-backgroundCircleBackground color for the label (center) in "circle" mode