获取UI表单以在GAS中的HTML表格内呈现 [英] Getting UI form to render inside HTML table in GAS

查看:127
本文介绍了获取UI表单以在GAS中的HTML表格内呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google协作平台中,我试图在html表格的行中添加一个由文本框和提交按钮组成的简短表单。表格中每一行的表格的一个副本。我试图为每个表格行收集输入数据。



HTML文件:

 < HTML> 
...
function showForm(){// https://developers.google.com/apps-script/gui_builder#including
var app = UiApp.createApplication();
app.add(app.loadComponent(myGui));
返回应用程序;
}
...
< table>< tr>< td><?= showForm()?>< / td>< / tr>< /表>
...
< / html>

然后使用HtmlService在我的.gs文件中的doGet()函数中调用.html文件。 createTemplateFromFile()方法。

表格正确呈现,除了我希望表单出现的地方,我改为使用文本/字符串UiApplication而不是文本框+提交按钮组合。



我在正确的轨道上吗?请帮助。

解决方案

这是错误的路径。



混音&匹配来自 HtmlService UiApp 的组件。 GUI Builder是一个打包的 UiApp 组件。



只需使用FlexTable并使用builder组件填充表格单元格。但不要忘记设置一个前缀:

  var flextab = app.createFlexTable(); (row = 0; ...)
for(col = 0; ...)
flextab.setWidget(row,col,app.loadComponent(myGui,{前缀:row+ row +col+ col});

在您的web应用程序中只有一个 UiInstance ,请仅调用一次 UiApp.createApplication()如果您稍后需要 UiInstance 你可以在 UiApp.getActiveApplication()中找到它。


In Google Sites, I am trying to add a short form consisting of a text box and a submit button as a cell in a row inside an html table. One copy of the form for each row in the table. I am trying to collect input data for each table row.

HTML File:

<html>
  ...
  function showForm(){ // https://developers.google.com/apps-script/gui_builder#including
    var app=UiApp.createApplication();
    app.add(app.loadComponent("myGui"));
    return app;
  }
  ...
  <table><tr><td><?=showForm()?></td></tr></table>
  ...
</html>

I then call the .html file from my doGet() function in my .gs file using HtmlService.createTemplateFromFile() method.

The table renders properly, except where I expect the form to appear, I instead get the text/string "UiApplication" instead of the text box + submit button combo.

Am I on the right track? Please help.

解决方案

It's the wrong track.

You can't mix & match components from HtmlService and UiApp. GUI Builder is a packaged UiApp component.

Just stick with a FlexTable and fill the table cells with your builder component. But don't forget to set a prefix:

var flextab = app.createFlexTable();
for (row=0; ...)
  for (col=0; ...)
    flextab.setWidget(row, col, app.loadComponent("myGui", {"prefix": "row"+row+"col"+col});

BTW - you can only have one UiInstance in your web app. Call UiApp.createApplication() only once. If you need the UiInstance later on, you can always find it with UiApp.getActiveApplication().

这篇关于获取UI表单以在GAS中的HTML表格内呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆