An options object defines the view and functionality available for users. Popular use cases:

  • Enable/disable filtering and sorting
  • Show/hide subtotals and grand totals
  • Define the formatting pattern for date and time

The options object consists of grid options and general options. More details can be found in the following sections:

  1. List of options defining the grid view and functionality
  2. List of options applicable to the whole component
  3. How to set options
  4. Example

Grid Options

Name Type Description
grid.type String Selects the grid form. Supported types are: "compact", "flat" and "classic". Default value: "compact".
grid.title String Specifies the grid title. Default value: "".
grid.showFilter Boolean Indicates whether the filtering feature is enabled (true) or not (false). Default value: true.
grid.showHeaders Boolean Indicates whether the headers on the spreadsheet are visible (true) or not (false). Default value: true.
grid.showTotals String Specifies how the subtotals are shown: either only for columns ("columns"), only for rows ("rows") or for columns and rows ("on"). To hide the subtotals completely, set this property to "off". Default value: "on".
grid.showGrandTotals String Specifies how the grand totals are shown: either only for columns ("columns"), only for rows ("rows") or for rows and columns ("on"). To hide grand totals completely, set this property to "off". Default value: "on".
grid.showHierarchies Boolean Specifies how multi-level hierarchies are shown on the grid: either with the icon on the left (false) or with the link on the right (true). Default value: true.
grid.showHierarchyCaptions Boolean Specifies whether the hierarchy captions are visible on the grid (true) or not (false). Default value: true.
grid.showReportFiltersArea Boolean Indicates whether the report filtering cells on the grid are visible (true) or not (false). Default value: true.

General Options

Name Type Description
configuratorActive Boolean Indicates whether the Field List is closed (false) or opened (true). Default value: false.
configuratorButton Boolean Indicates whether the Field List button is visible (true) or not (false). Default value: true.
showAggregations Boolean Indicates if the aggregation selection control for measures is visible in the Field List (true) or not (false). Default value: true.
showCalculatedValuesButton Boolean Specifies whether the “Add calculated value” button is visible in the Field List (true) or not (false). Default value: true.
drillThrough Boolean Specifies whether the drill-through feature is enabled (true) or not (false). The cell can be drilled through by double-clicking the cell. Default value: true.
showDrillThroughConfigurator Boolean Specifies whether the Field List button is visible in the drill-through pop-up window. Default value: true.
sorting String Specifies whether the sorting controls are visible in columns ("columns"), rows ("rows") or in columns and rows at the same time ("on"). The controls can be hidden by setting this parameter to "off". Default value: "on".
datePattern String This property is used for formatting of “date string” date fields ("type":"date string" in the JSON data source, the "ds+" prefix in CSV). Default pattern string: dd/MM/yyyy.
dateTimePattern String This property is used for formatting “datetime” date fields ("type":"datetime" in the JSON data source, the "dt+" prefix in CSV). Default pattern string: dd/MM/yyyy HH:mm:ss.
saveAllFormats Boolean If there are more than 5 formats defined in the report, only the formats for currently displayed measures are saved in the report. Set saveAllFormats property to true to save all the formats defined in the report. Default value: false.
showDefaultSlice Boolean

Specifies whether the default slice can be selected automatically (for cases when the slice is not set in the report). If showDefaultSlice is true, the first hierarchy from the data source is put into rows and the first measure is put into columns. If showDefaultSlice is false, the grid remains empty. Default value: true.

defaultHierarchySortName String Specifies a type of sorting for the hierarchy members. Possible values are "desc" (descending), "asc" (ascending) or "unsorted". Default value: "asc".
showAggregationLabels Boolean Specifies whether the aggregation labels like "Sum of", "Total Sum of", etc. are displayed in the row and column titles. Aggregation labels can be changed in a JSON localization file. Default value: true.

How to set options

Initially, all the options are set to their default values. Setting options that differ from the defaults can be done in 3 ways:

  1. Specifying options in the report. Here is an example of setting a grid type:
    {
        "dataSource": {
            "filename": "https://cdn.webdatarocks.com/data/data.csv"
        },
        "options": {
            "grid": {
                "type": "classic"
            }
        }
    }
    

    The CodePen example.

  2. Using setOptions() and refresh() API calls.

    2.1. Here is an example of setting a grid title:

    webdatarocks.setOptions({
    	grid: {
    		title: "A New Title"
    	}
    });
    webdatarocks.refresh();
    

    Try the CodePen example.

    2.2. An example of disabling sorting:

    webdatarocks.setOptions({
    	sorting: "off"
    });
    webdatarocks.refresh();
    

    Try the CodePen example.

  3. Via the Toolbar. Click on the Options tab to change the form of the pivot table or the look of grand totals and subtotals:

Example

A live demo with setting grid options:

More information