Get Free Trial
  1. API reference
Connecting to Data Source
Configuring the component
  • Documentation for older versions
  • Table of contents

    Configuring global options

    Flexmonster has a wide variety of configurable options: localization, grid options, chart options, etc.

    ReportObjects are used to configure which data should be shown in the component, how it will be visualized, and what instruments will be available for data analysis. The values for all the possible options can be defined in the report. Details on how to configure all options in the report are described in the configuring report set of articles.

    It is not mandatory to explicitly set all the options in the report. When a value for an option is not set in the report, it is pulled from the default values that are predefined in the component.

    It is however often simpler to modify specific default options that will be common for all reports. This can be done using the GlobalObject. global is a parameter of the new Flexmonster() method.

    In general, the GlobalObject should be considered as a global parent report. It can have a dataSource, options, and localization sub-objects. The global object overrides the default option values for all the reports of the component. Thus, the component will use the global value if a specific option is not explicitly set in the report.

    Examples

    1) Specify one localization for all reports:

    global: {
    localization: "loc/es.json"
    }

    Check out an example on JSFiddle.

    2) This example demonstrates how to set common options for all reports:

    global: {
      options: {
        readOnly: true
      }
    }

    Check out an example on JSFiddle.

    3) Apply date and time formatting for "date string" date fields in the component:

    global: {
      options: {
        datePattern: "'Date: 'MM/dd/yy"
      }
    }

    Check out an example on JSFiddle.

    4) The next example shows how you can specify the data source for all reports:

    global: {
      dataSource: {
        filename: "https://cdn.flexmonster.com/data/data.csv"
      }
    }

    Check out an example on JSFiddle.

    5) The current report is usually obtained via the save() or getReport() API calls. By default, reports returned by these methods contain only the options that were explicitly defined inside the ReportObject. For example, if we have the component defined like this:

    let pivot = new Flexmonster({
    container: "pivotContainer",
    global: {
    localization: "loc/es.json"
    },
    report: {
    dataSource: {
    filename: "https://cdn.flexmonster.com/data/data.csv"
    }
    }
    });

    save() and getReport() will get the report containing the specified dataSource, but without any options defined in global or defaults. Use the withGlobals: true parameter in the API calls to include localization that was defined in global in the report:

    save()

    flexmonster.save({
    withGlobals: true
    });

    getReport()

    flexmonster.getReport({
    withGlobals: true
    });

    To include the default options in the report, use the withDefaults: true parameter:

    save()

    flexmonster.save({
    withDefaults: true
    });

    getReport()

    flexmonster.getReport({
    withDefaults: true
    });

    Check out an example on JSFiddle.

    What’s next?

    You may be interested in the following articles: