다음은 세 개의 대화 상자가 차례대로 표시되어 있고 CacheService 개체를 통해 상태/데이터를 유지 관리하는 예입니다.
는 희망이이 UI Builder에서 각 대화에 포함 된 내용을 설명하지 않고 의미가 있습니다 (당신은 ... 각 그래도 자신의 범위를 가지고, 대안으로 UserProperties, ScriptProperties 또는 숨겨진 필드를 사용할 수 있습니다).
function showDialog1(){
var app = UiApp.createApplication();
app.add(app.loadComponent("Dialog1"));
SpreadsheetApp.getActiveSpreadsheet().show(app);
}
function onDialog1OKButton(e){
CacheService.getPrivateCache().put("n1", e.parameter.n1);
var app = UiApp.getActiveApplication();
var d2 = app.loadComponent("Dialog2");
app.add(d2);
SpreadsheetApp.getActiveSpreadsheet().show(app);
}
function onDialog2OKButton(e){
var c = CacheService.getPrivateCache();
c.put("n2", e.parameter.n2);
var app = UiApp.getActiveApplication();
app.add(app.loadComponent("DialogResult"));
var n1 = c.get("n1");
var n2 = c.get("n2");
var l = app.getElementById("Label2");
l.setText("" + n1 + " + " + n2 + " = " + (parseInt(n1) + parseInt(n2)));
SpreadsheetApp.getActiveSpreadsheet().show(app);
}
감사합니다. 이상하게도 우리는 많은 UI를 만들 수 있습니다. – Vincent
사실 UiApp 인스턴스가 동일하기 때문에 모듈화 된 컨텐츠를 가진 하나의 UI와 같습니다. –