我一直在尝试创建一个通过自定义电子表格菜单部署的 UiApp。我的问题是,当调用服务器处理程序时,似乎没有返回包含原始 Ui 代码的“main”或“doGet”函数的好方法。
通常,当从服务器处理程序返回时,会使用以下内容:
app.close();
return app;
但是,在电子表格中部署 Ui 时,建议使用以下内容来显示 Ui:
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.show(app);
我已经尝试了我似乎可以找到的两种方法的每一种组合,当调用处理程序或崩溃时,UI 要么关闭。
请帮忙!我在下面包含了我的代码:
function onOpen() { //call to invoke the menu when opening the spreadsheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
var reportMenu = [{name: "Edit Reports", functionName: "deploy"}];
ss.addMenu("Reports", reportMenu);
}
function deploy() {
var app = UiApp.createApplication();
var form = app.createFormPanel();
var flow = app.createFlowPanel();
//creating handlers
var LB1handler = app.createServerClickHandler('checkSelect_');
LB1handler.addCallbackElement(flow);
//creating the flow...
flow.add(app.createLabel("Reports Interface:").setId("l1"));
flow.add(app.createLabel("What would you like to do?"));
flow.add(app.createListBox().addItem("Create a new report").addItem("Edit an Existing Report").setName("LB1"));
flow.add(app.createSubmitButton('Submit').addClickHandler(LB1handler));
form.add(flow);
app.add(form);
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.show(app);
}
function checkSelect_(e) {
var app = UiApp.getActiveApplication();
//do some stuff to the app
//but how to get back??????
//return app;
// var ss = SpreadsheetApp.getActiveSpreadsheet();
// ss.show(app);
}
//end code
感谢您的任何帮助!