orb.pgridwidget
Options
dataSource
Pivot grid data source array. It can contain arrays or objects. When it is an array of objects, field names are object properties. When it is an array of arrays, field names are array indexes.
Type: Array
Default: null
dataHeadersLocation
Data headers location: 'rows'
or 'columns'
.
Type: String
Default: 'rows'
canMoveFields
Whether or not user can move fileds at runtime.
Type: Boolean
Default: true
grandTotal
Grand total settings. It contains the following sub options:
- rowsvisible: grand total row visibility
- columnsvisible: grand total column visibility
Type: Object
Default: { rowsvisible: true, columnsvisible: true }
subTotal
Global subtotals settings for row and column fiels. It contains the following sub options:
- visible: sub total rows visibility
- collapsible : sub total rows can be collapsed or not
- collapsed: sub total rows initial collapsed state
Type: Object
Default: { visible: true, collapsible: true, collapsed: false }
rowSettings
Global subtotals settings for row fields. It contains the following sub options:
Type: Object
Default: { subTotal: { visible: true, collapsible: true, collapsed: false }, sort: { order: null, customfunc: null } }
columnSettings
Global subtotals settings for column fields. It contains the following sub options:
Type: Object
Default: { subTotal: { visible: true, collapsible: true, collapsed: false }, sort: { order: null, customfunc: null } }
fields
Pivot grid fields mapping to data source fields. See Field options
Type: Array<Pivot grid field>
Default: null
rows
Array containing initial rows axe fields. It can contain:
- Pivot grid field objects
- Field names
- Field captions
Fields in this array should be defined first in the fields array.
Type: Array<Pivot grid field>
Default: null
columns
Array containing initial columns axe fields. It can contain:
- Pivot grid field objects
- Field names
- Field captions
Fields in this array should be defined first in the fields array.
Type: Array<Pivot grid field>
Default: null
data
Array containing initial data axe fields. It can contain:
- Pivot grid field objects
- Field names
- Field captions
Fields in this array should be defined first in the fields array.
Type: Array<Pivot grid field>
Default: null
preFilters
Defines how to filter data source before first building the pivot grid. Each property should map to either the caption or the name of one of the datasource fields. Property value should be an object with a single property having its name being one of the following operators:
- Matches
- Does Not Match
- =
- <>
- >
- >=
- <
- <=
And its value being either:
- An array, in which case field values not belonging to this array will be filtered out.
- A regular expression. Only valid for Matches and Does Not Match operators.
- A value. Field values will be compared to this value using the operator in the property name.
String comparison and regular expressions searches are always case-insensitive.
Example:
preFilters : {
'Manufacturer': { 'Matches': /^c/i }, // Keep only Manufacturers starting with 'c'
'Category' : { 'Does Not Match': 'D' }, // Keep Categories that does not contain 'd'
'Amount' : { '>': 40 }, // Keep only Amounts > 40
'Q' : [4, 8, 12] // Keep Quantites in [4, 8, 12]
}
Type: Object
Default: null
toolbar
Toolbar configuration object:
- visible: Whether or not to show the toolbar (default
false
).
The toolbar contains the following buttons:
- Collapse/Expand all rows/columns
- Show/hide rows/columns sub-totals
- Show/hide rows/columns grand-total
- Export to Excel
Type: Object
Default: { visible: false }
theme
Defines Pivot grid theme. Should be one of the following values:
red | |
blue | |
green | |
orange | |
flower | |
gray | |
white | |
black | |
bootstrap |
N.B.: bootstrap theme needs bootstrap css files to render properly.
Type: String
Default: 'blue'
width
Pivot grid width in pixel. A horizontal scroll bar appears when data to display needs more space. By default, the pivot grid extends horizontally as much as it needs.
Type: Number
Default: null
height
Pivot grid height in pixel. A vertical scroll bar appears when data to display needs more space. By default, the pivot grid extends vertically as much as it needs.
Type: Number
Default: null
Field options
A pivot grid field object is what describes the properties of a field when belonging to the different axes. It can be used in the fields, rows, columns and data options of the pivot grid.
Field options defined for rows, columns and data are only used when the pivot grid is first rendered and while the fields are not moved to other axes. These settings override the ones in fields.
Properties
name
Data source property name that this field will map.
Type: String
Default: null
caption
Field caption (displayed on buttons, ...).
Type: String
Default: field.name
subTotal
Same as pivot grid subTotal option but only applicable to current field. Overrides the global subtotal option.
Type: Object
Default: { visible: true, collapsible: true, collapsed: false }
sort
Defines sort settings:
- order: field sort order:
'asc'
/'desc'
- customfunc: custom sort function
Type: Object
Default: { order: null, customfunc: null }
aggregateFunc
Aggregate function when the field is dropped into the data axe. It can be one of the following predefined constants:
'sum'
: sum of the values'count'
: count of the values'min'
: min of the values'max'
: max of the values'avg'
: average of the values'prod'
: product of the values'var'
: estimate of the variance of the values, where they are considered as a subset of the entire population'varp'
: estimate of the variance of the values, where they are considered as the entire population'stdev'
: estimate of the standard deviation of the values, where they are considered as a subset of the entire population'stdevp'
: estimate of the standard deviation of the values, where they are considered as the entire population
It can also be a custom aggregation function having the following signature:
function(datafield, intersection, datasource, rowIndexes, colIndexes): number
Where:
datafield
: the name of the datafield for which the aggregation is calculatedintersection
: indexes in the data source array of all rows that will participate in this aggregation = drill down result of current cell. If the entire data source is included, this parameter will be equal to 'all'.datasource
: data source arrayrowIndexes
: cell rows axe indexes in the data source arraycolIndexes
: cell columns axe indexes in the data source array
Returns:
aggregation result
Type: Object
Default: 'sum'
formatFunc
Data cell formatting function when the field is dropped into the data axe.
Signature: function(value)
, value
: raw numeric value
Returns: formatted value to display in pivot grid data cells
Type: Function
Default: .toString()
rowSettings
Settings to use when this field is dropped in the rows axe.These settings override pivot grid fields settings.
Type: Pivot grid field
Default: null
columnSettings
Settings to use when this field is dropped in the columns axe.These settings override pivot grid fields settings.
Type: Pivot grid field
Default: null
dataSettings
Settings to use when this field is dropped in the data axe.These settings override pivot grid fields settings.
Type: Pivot grid field
Default: null
Methods
changeTheme
Changes the theme of the pivot grid. See theme option for possible values of themeName. If themeName is not valid, 'blue'
theme will be applied.
Signature: changeTheme(themeName)
Returns: undefined
refreshData
Changes the datasource of the pivot grid. The pivot grid will be rebuilt, but sorting, filtering, sub totals collaped state will be retained.
Signature: refreshData(dataArray)
Returns: undefined