All documentation
  • Introduction
  • Connecting to data source
  • Browser compatibility
  • Documentation for older versions
  • Global configurations

    This guide shows how to specify configurations that will be common for all reports using the GlobalObject. The following configurations can be specified for all reports:

    The GlobalObject should be considered as a global parent report. The component will use the global value if a specific configuration is not explicitly set in the report.

    Specify a global data source

    To specify a data source for all reports, configure the global.dataSource property:

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

    Live example

    For more info about available data source configurations, check out the Data source guide.

    Specify global options

    To specify options for all reports, configure the global.options property. 

    The following example demonstrates how to specify the readOnly option for all reports:

    global: {
      options: {
        readOnly: true
      }
    }

    Live example

    In the next example, we apply date and time formatting for all reports using the datePattern option:

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

    Live example

    Read more about available options in the Options guide.

    Specify a global localization

    To specify a localization for all reports, configure the global.localization property:

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

    Live example

    To learn more about localization, read the Localizing the component guide.

    Save the report with global configs

    The current report is usually obtained via the save() or getReport() API calls. By default, reports returned by these methods contain only the configurations that were explicitly specified inside the ReportObject.

    For example, we have the component defined like this:

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

    By default, save() and getReport() will return the report with the specified dataSource property, but without the localization. Use the withGlobals: true parameter in the API calls to include the localization that was defined in the global parameter:

    save()

    pivot.save({
    withGlobals: true
    });

    getReport()

    pivot.getReport({
    withGlobals: true
    });

    Live example

    What's next?

    You may be interested in the following articles: