Auto Refresh Google Apps Scripts Webapp Ui?
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:
- Make a spreadsheet
- add a service for posting
- have service update spreadsheet
- 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?"