PercentColumn
A column that either displays a basic percent number, a rectangular progress bar, or a circular progress bar.
//<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-zeroCSS class is added to the circle element. - If value is less than lowThreshold, a
b-lowCSS class is added to the bar element. - If value equals 100, a
b-fullCSS class is added to the bar element. - If value is > 100, a
b-overCSS 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-emptyCSS class is added to the circle element. - If value equals 100, a
b-fullCSS class is added to the circle element. - If value is > 100, a
b-overCSS class is added to the circle element.
Default editor is a NumberField.
Configs
89
Configs
89Common
Rendering
When below this percentage the bar will have b-low CSS class added. By default, it turns the bar red.
This mode controls the rendering.
numberto render a formatted number value (e.g. 15%)circleto render a circular progress barbarto render a plain rectangular progress bar
Set to true to render the number value inside the bar, for example '15%'.
Integration
Interaction
Menu
Misc
Properties
160
Properties
160Common
Class hierarchy
Rendering
When below this percentage the bar will have b-low CSS class added. By default, it turns the bar red.
This mode controls the rendering.
numberto render a formatted number value (e.g. 15%)circleto render a circular progress barbarto render a plain rectangular progress bar
Set to true to render the number value inside the bar, for example '15%'.
Editing
Integration
Interaction
JSON
Menu
Misc
Other
Parent & children
Functions
77
Functions
77Other
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;
}
}
]
}
| Parameter | Type | Description |
|---|---|---|
rendererData | Object | The data object passed to the renderer |
rendererData.value | Number | The value to display |
DomConfig object representing the default markup for the cells content
Configuration
Editing
Events
Identification
Misc
Parent & children
Events
5
Events
5Event handlers
5
Event handlers
5Typedefs
2
Typedefs
2CSS variables
16
CSS variables
16| Name | Description |
|---|---|
--b-percent-column-bar-border-radius | BarPercent bar border radius |
--b-percent-column-bar-max-height | BarPercent bar max height |
--b-percent-column-bar-border | BarPercent bar border |
--b-percent-column-circle-thickness | CircleThickness of the outer circle in "circle" mode |
--b-percent-column-circle-label-font-size | CircleLabel font size in "circle" mode |
--b-percent-column-bar-background | BarPercent bar background color (the "empty" part of the bar) |
--b-percent-column-low-fill-background | BarFill color for the bar when value is below `lowThreshold` |
--b-percent-column-wide-value-color | BarValue label's color when the bar is wide, and label gets moved inside the bar |
--b-percent-column-low-value-color | BarValue label's color when the value is below `lowThreshold` |
--b-percent-column-zero-value-color | BarValue label's color when the value is zero |
--b-percent-column-circle-background | CircleBackground color for the circle in "circle" mode |
--b-percent-column-circle-label-color | CircleValue label's color in "circle" mode |
--b-percent-column-fill-background | BarFill color for the bar (the "filled" part of the bar) |
--b-percent-column-value-color | Value label's color |
--b-percent-column-circle-done-color | CircleColor of the filled part of the circle in "circle" mode |
--b-percent-column-circle-label-background | CircleBackground color for the label (center) in "circle" mode |