Skip to content Skip to sidebar Skip to footer

Auto Refresh Google Apps Scripts Webapp Ui?

I have created a simple webapp using Google Apps Scripts. The UI simply displays a couple of numbers being continuous updated in a FusionTable. A custom data acquisition system i

Solution 1:

You can use the UiInstance.addTimer method for auto refresh, but it's not documented and maybe not supported.

Its syntax is UiInstance.addTimer( ServerHandler , interval);

See the sample code below.

functiondoGet(e) {

  var app = UiApp.createApplication();

  

  app.add(app.createLabel(newDate()).setId("label"));

  

  app.addTimer(app.createServerHandler("update") , 1000);

  

  return app;

}



functionupdate(e){

  var app = UiApp.getActiveApplication();

  app.getElementById("label").setText(newDate());

  app.addTimer(app.createServerHandler("update") , 1000);


  return app;

}

A sample app can be found here.

Solution 2:

Use a spreadsheet for display. They autoupdate.

Stackoverflow, this is not a thanks but the solution, but for you:

  1. Make a spreadsheet
  2. add a service for posting
  3. have service update spreadsheet
  4. watch spreadsheet

Solution 3:

Unfortunately, Google Apps Script doesn't yet have a timer facility to update the UI at frequent intervals. However, there is a hack that I wrote a while back and is available in the old Apps Script forum at http://productforums.google.com/forum/#!topic/apps-script/2pqhh_eTIvQ

There have been refinements over that you can search for in stackoverflow, but the basic premise remains the same i.e. you exploit the fact that you can programatically change the value of a checkbox AND trigger its change handler.

Post a Comment for "Auto Refresh Google Apps Scripts Webapp Ui?"