This documentation page assumes that you already have a SeekTable account. Create your free account by signing up.

Restore Embedded Report State

When embedded report has report parameters (inputs) in some cases it is useful to save user-entered values and restore them on next time when the report is opened. This behaviour may be easily added with simple JS code that should be added to the 'host' web page in addition to the iFrame:

  1. Your account needs to have an active Advanced Publishing subscription. You may activate a free 14-day trial on the "Manage Account" view (top-right menu).
  2. Use parameter_change_notify=1 URL parameter in iFrame's src to enable a callback from iFrame to the 'parent' web-page; in this way you'll able to save user's input each time when parameters are changed. For example:
    <iframe id="embedded_report" name="embedded_report" border="0" frameborder="0" 
      width="800" height="600" scrolling="no" style="overflow:hidden"      
      src="https://www.seektable.com/public/report/1b0509d283904b4995f6968bdd4793f7?parameter_change_notify=1&parameter=filter_year,filter_country"></iframe>
    
  3. Add the following code to the 'host' web page to handle this callback:
    window.addEventListener("message", function (event) {
      if (!event.data) return;
      var msg = JSON.parse(event.data);
      switch (msg.action) {
        case "onReportParametersChanged":
          console.log('save='+JSON.stringify(msg.result));
          // js code that saves parameters for the report in the iFrame is here
          break;
      }
    });
    
  4. Next time when host page is opened saved report parameters may be passed to iFrame with report_parameters in the iFrame's URL.

Online demo that saves embedded report parameters in the localStorage: https://jsfiddle.net/k1d7Lrhm/2/