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.
To specify a data source for all reports, configure the global.dataSource property:
global: { dataSource: { filename: "https://cdn.flexmonster.com/data/data.csv" } }
For more info about available data source configurations, check out the Data source guide.
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 } }
In the next example, we apply date and time formatting for all reports using the datePattern option:
global: { options: { datePattern: "'Date: 'MM/dd/yy" } }
Read more about available options in the Options guide.
To specify a localization for all reports, configure the global.localization property:
global: {
localization: "loc/es.json"
}
To learn more about localization, read the Localizing the component guide.
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:
pivot.save({
withGlobals: true
});
pivot.getReport({
withGlobals: true
});
You may be interested in the following articles: