Menu
Download Free Trial
  1. API reference
  2. Welcome
    1. Component overview
    2. Quickstart
    3. System requirements
    4. Troubleshooting
    5. Installation troubleshooting
    6. Managing license keys
  3. Connecting to Data Source
    1. JSON
      1. Connecting to JSON
      2. Data types in JSON
    2. CSV
      1. Connecting to CSV
      2. Data types in CSV
    3. SQL database
      1. Connecting to SQL database
      2. Connecting to database with .NET
      3. Connecting to database with .NET Core
      4. Connecting to database with Java
      5. Connecting to database with PHP
    4. Microsoft Analysis Services
      1. Connecting to Microsoft Analysis Services
      2. Getting started with Accelerator
      3. Installing Accelerator as a Windows Service
      4. Configuring username/password protection
      5. Configuring secure HTTPS connection
      6. Troubleshooting
    5. Pentaho Mondrian
      1. Connecting to Pentaho Mondrian
      2. Getting started with Accelerator
      3. Configuring Mondrian roles
      4. Сonfiguring username/password protection
      5. Сonfiguring secure HTTPS connection
      6. Troubleshooting
    6. icCube
  4. Configuring report
    1. What is a report
    2. Data source
    3. Slice
    4. Options
    5. Number formatting
    6. Conditional formatting
    7. Set report to the component
    8. Get report from the component
    9. Date and time formatting
    10. Configuring global options
    11. Export and print
    12. Calculated values
    13. Custom sorting
  5. Integration with frameworks
    1. Available tutorials
    2. Integration with jQuery
    3. Integration with AngularJS
    4. Integration with Angular 2
    5. Integration with Angular 4
    6. Integration with React
    7. Integration with RequireJS
    8. Integration with TypeScript
    9. Integration with ASP.NET
    10. Integration with JSP
    11. Integration with PhoneGap
  6. Integration with charts
    1. Integration with Highcharts
    2. Integration with FusionCharts
    3. Integration with Google Charts
    4. Integration with any charting library
  7. Customizing
    1. Customizing toolbar
    2. Customizing appearance
    3. Localizing component
  8. Updating to the latest version
    1. Updating to the latest version
    2. Release notes
    3. Migration guide from 2.3 to 2.4
    4. Migration guide from 2.2 to 2.3
  9. Older Versions
    1. Documentation 2.3
    2. Documentation 2.2
    3. API reference - Flex
Table of contents

Integration with jQuery

This tutorial will help you to integrate Pivot Table Component with jQuery library. Follow the steps to set up a simple project:

Step 1: Create a new jQuery project

  1. Create a new folder for the project, e.g. my-jquery-project/.
  2. Copy flexmonster/ folder into your project folder. You can find flexmonster/ inside of the package you have downloaded from the site.
  3. Create index.html file inside my-jquery-project/ and include jquery:
    <!DOCTYPE html>
    <html>
    <head>
        <title>My jQuery/Flexmonster Project</title>
    </head>
    <body>
        <script src="flexmonster/lib/jquery.min.js"></script>
    </body>
    </html>
    

Step 2: Add Flexmonster dependencies

  1. Create <div> container for the component:
    <!DOCTYPE html>
    <html>
    <head>
        <title>My jQuery/Flexmonster Project</title>
    </head>
    <body>
        <div id="pivotContainer">The component will appear here</div>
        <script src="flexmonster/lib/jquery.min.js"></script>
    </body>
    </html>
    
  2. Add Flexmonster library to the index.html:
    <!DOCTYPE html>
    <html>
    <head>
        <title>My jQuery/Flexmonster Project</title>
    </head>
    <body>
        <div id="pivotContainer">The component will appear here</div>
        <script src="flexmonster/lib/jquery.min.js"></script>
        <script src="flexmonster/flexmonster.js"></script>
    </body>
    </html>
    

Step 3: Initialize Pivot Table

Add simple script to embed the component. Please note, licenseKey is your license or trial key, so you should replace XXXX-XXXX-XXXX-XXXX-XXXX with an actual key:

<!DOCTYPE html>
<html>
<head>
    <title>My jQuery/Flexmonster Project</title>
</head>
<body>
	<div id="pivotContainer">The component will appear here</div>
	<script src="flexmonster/lib/jquery.min.js"></script>
	<script src="flexmonster/flexmonster.js"></script>
	
	<script>
		var pivot = $("#pivotContainer").flexmonster({
			toolbar: true,
			licenseKey: "XXXX-XXXX-XXXX-XXXX-XXXX"
		});
	</script>
	
</body>
</html>

Step 4: Load sample report

To see some data on grid add report attribute with report URL:

<!DOCTYPE html>
<html>
<head>
    <title>My jQuery/Flexmonster Project</title>
</head>
<body>
	<div id="pivotContainer">The component will appear here</div>
	<script src="flexmonster/lib/jquery.min.js"></script>
	<script src="flexmonster/flexmonster.js"></script>
	
	<script>
		var pivot = $("#pivotContainer").flexmonster({
			toolbar: true,
			report: "https://cdn.flexmonster.com/reports/report.json",
			licenseKey: "XXXX-XXXX-XXXX-XXXX-XXXX"
		});
	</script>
</body>
</html>

Check out the sample on JSFiddle. Should you have any problems — visit our troubleshooting section.

Initial jQuery call to embed the component

$(“#pivotContainer”).flexmonster({
    componentFolder: String,
    global: ReportObject,
    width: Number,
    height: Number,
    report: ReportObject | String,
    toolbar: Boolean,
    customizeCell: Function,
    licenseKey: String
})

[starting from version: 2.3]

Embeds the component into the HTML page.
As a parameter jQuery call gets #pivotContainer – id of the HTML element you would like to have as a container for the component.
This method allows you to insert the component into your HTML page and to provide it with all necessary information for the initialization.

Starting from version 2.3 you can preset options for all reports using global object.

Note: Please do not forget to import jQuery and flexmonster.js before you start working with it.

Parameters

    • componentFolder – URL of the component’s folder which contains all necessary files. Also, it is used as a base URL for report files, localization files, styles and images. The default value for componentFolder is flexmonster/.
    • global – object that allows you to preset options for all reports. These options can be overwritten for concrete reports. Object structure is the same as for Report Object.
    • width – width of the component on the page (pixels or percent). The default value for width is 100%.
    • height – height of the component on the page (pixels or percent). The default value for height is 500.
    • report – property to set a report. It can be inline Report Object or URL to report JSON. XML reports are also supported in terms of backward compatibility.
    • toolbar – parameter to embed the toolbar or not. Default value is false – without the toolbar.
    • customizeCell – function that allows customizing of separate cells.
    • licenseKey – the license key.

Event handlers can also be set as properties for the jQuery call. Check the list here.

    All the parameters are optional. If you run $("#pivotContainer").flexmonster() – empty component without the toolbar will be added with the default width and height.

    Returns

    Object, the reference to the embedded pivot table. If you want to work with multiple instances on the same page use these objects. All API calls are available through them.

    After initialization, you can obtain an instance reference of the created component by selector as following: var pivot = $("#pivot").data("flexmonster");

    Installation troubleshooting

    If you are facing any problems with the embedding of the component, in your browser go to the page where the Flexmonster component should be displayed and open the browser’s console to check if you have any errors in the console. Try the following steps:

    • If you get the alert "Flexmonster: jQuery is not loaded.", check the path to jquery.min.js in your HTML page.
    • If the page is blank and you see the following error in the console: "Uncaught TypeError: $(...).flexmonster is not a function", check the path to flexmonster.js in your HTML page.
    • If you get the alert "Unable to load dependencies. Please use 'componentFolder' parameter to set the path to 'flexmonster' folder.", add componentFolder parameter to your $.flexmonster() call. Pay attention to the message "Files not found: ..." and set componentFolder to receive the correct paths to lib/jqueryui.min.js, lib/jqueryhelpers.min.js and flexmonster.css.
      <div id="pivotContainer">The component will appear here</div>
      <script src="flexmonster/lib/jquery.min.js"></script>
      <script src="flexmonster/flexmonster.js"></script>
      
      <script>
        var pivot = $("#pivotContainer").flexmonster({
          toolbar: true,
          licenseKey: "XXXX-XXXX-XXXX-XXXX-XXXX",
          // set the appropriate path
          componentFolder: "",
        });
      </script>
      
    • If you get the error "Uncaught TypeError: Cannot set property '_generatePosition' of undefined" or something alike, try to update jQuery UI. Use minimum recommended version 1.9.2 or later.
    • If you get the error "Uncaught TypeError: $.parseXML is not a function" or something alike, try to update jQuery. Use minimum recommended version 1.7 or later.