JSFiddle - React, Tailwind, and code Playground

by Kishoreajey

HTML

<script src="http://code.jquery.com/jquery-2.1.0.js"></script>
<!-- Provide the URL to visualize.js -->
<script src="https://mobiledemo.jaspersoft.com/jasperserver-pro/client/visualize.js"></script>
<select id="selectCity"></select>
<button id="previousPage">Previous Page</button>
<button id="nextPage">Next Page</button>
<!-- Provide a container for the main report -->
<div>
  <div style="width:20px;"></div>
  <div style="width:500px;" id="main"></div>
</div>

CSS

#main {
  float: left;
}

JavaScript

visualize({
  auth: {
    name: "jasperadmin",
    password: "jasperadmin",
    organization: "organization_1"
  }
}, function(v) {
  var $select = $("#selectCity"),
    report = v.report({
      resource: "/MyReports/Drill_Reports_with_Controls/main_report",
      container: "#main",
      success: refreshSelect,
      error: showError
    });

  function refreshSelect(data) {
    console.log(data);
    var options = data.links.reduce(function(memo, link) {
      console.log(link);
      return memo + "" + link.tooltip + "";
    }, "");
    $select.html(options);
  }
  $("#previousPage").click(function() {
    var currentPage = report.pages() || 1;
    goToPage(--currentPage);
  });
  $("#nextPage").click(function() {
    var currentPage = report.pages() || 1;
    goToPage(++currentPage);
  });

  function goToPage(numder) {
    report
      .pages(numder)
      .run()
      .done(refreshSelect)
      .fail(showError);
  }

  function showError(err) {
    alert(err.message);
  }
});