Get Free Trial

Integration with PhoneGap

NOTE: integration with PhoneGap is outdated and may not work with newer versions of Flexmonster.
We recommend using pure JavaScript or Flexmonster integrations with other frameworks.

This tutorial will help you integrate Flexmonster with PhoneGap. Follow these steps to set up a simple PhoneGap project with Flexmonster Pivot Table and Charts:

Step 1. Create a new PhoneGap project

  1. Open PhoneGap. If you don’t have it installed, download and install PhoneGap using these very detailed step by step instructions.
  2. Click File. filephonegap
  3. Choose Create new project.
  4. Choose the Hello World template and click Next.
  5. Enter the local path, the app name, and click Create project.
  6. Your project will run automatically. To see it, click on the IP address at the bottom of the PhoneGap window.
  7. You should see this default page in your browser.

Step 2. Add Flexmonster files

Copy flexmonster/ from the download package to the www/ folder. flexmonsterfolderphonegap

Step 3. Add Flexmonster dependencies

Inside www/index.html find the cordova.js file. Add the jQuery and Flexmonster libraries right before cordova.js.

<script type="text/javascript" src="flexmonster/lib/jquery.min.js"></script>
<script type="text/javascript" src="flexmonster/flexmonster.js"></script>
<script type="text/javascript" src="cordova.js"></script>

Step 4. Create the pivot table

  1. Open www/index.html and create a <div> container for the component inside the <p class="event received"></p> tags.
  2. Remove class="blink" from <div id="deviceready" class="blink">.
    <div class="app">
        <div id="deviceready">
          <p class="event listening">Connecting to Device</p>
          <p class="event received">
            <div id="pivotContainer" 
            style="position:absolute !important; left:0px; top:0px;"></div>
  3. Open www/js/index.js and add a simple script to embed the component inside the receivedEvent function. Note that licenseKey is your license or trial key, so replace XXXX-XXXX-XXXX-XXXX-XXXX with an actual key.
    // Update DOM on a Received Event
    receivedEvent: function(id) {
      var parentElement = document.getElementById(id);
      var listeningElement = parentElement.querySelector('.listening');
      var receivedElement = parentElement.querySelector('.received');
      listeningElement.setAttribute('style', 'display:none;');
      receivedElement.setAttribute('style', 'display:block;');
      console.log('Received Event: ' + id);
      var pivot = flexmonster.embedPivotComponent(
        "flexmonster/", "pivotContainer", "100%", "100%", 
          filename: "",
          licenseKey: "XXXX-XXXX-XXXX-XXXX-XXXX"
        }, true
  4. To see the pivot table embedded into the project, click the IP address at the bottom of the PhoneGap window.

Open www/css/index.css to configure the style of the component. For example, remove text-transform:uppercase; and letters will become lower case.

You can download the full example here.