管理两个用户界面的最佳方式是什么? [英] What is the best way to manage two UI's?
本文介绍了管理两个用户界面的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了两个用户界面。我如何关闭第一个并激活下一个?是否有可能在Google apps脚本下有两个用户界面?
我试过类似于:
var app = UiApp.getActiveApplication();
app.add(app.loadComponent(APPGui));
var panel1 = app.getElementById(LoginPanel1);
panel1.setVisible(false);
返回应用程序;
解决方案
以下是三个对话框的示例: ,通过 CacheService 对象维护它们之间的状态/数据。
<您可以使用UserProperties,ScriptProperties或者一个隐藏字段作为替代,每个人都有自己的范围,但...)
希望这不需要解释UI Builder中的每个对话框都包含了什么。
function showDialog1(){
var app = UiApp.createApplication();
app.add(app.loadComponent(Dialog1));
SpreadsheetApp.getActiveSpreadsheet()。show(app);
函数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);
}
函数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);
}
I have created two user interfaces. How can I close the first one and activate the next? Is it possible to have two UI under Google apps script?
I have try something like:
var app = UiApp.getActiveApplication();
app.add(app.loadComponent("APPGui"));
var panel1 = app.getElementById("LoginPanel1");
panel1.setVisible(false);
return app;
解决方案
Here's and example of three dialogs shown one after the other, maintaining state/data between them via the CacheService object.
(You could use UserProperties, ScriptProperties or even a Hidden Field as an alternative, each has their own scope though...)
Hopefully this makes sense without explaining what each dialog in the UI Builder contains.
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);
}
这篇关于管理两个用户界面的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文