Google 应用制作工具无法识别自己的一些小部件

Google App Maker not reocognising some of its own widgets

在 Google App Maker 中,我在一个页面上有几个小部件。 其中一个小部件称为 Label12(如屏幕截图 1 所示)。 它确实存在,并且也显示在我屏幕顶部的面包屑路径中。

然而,当我试图在我的代码中引用 Label12 时,它似乎并不存在。

如果我使用 ctrl+space 代码完成助手,Label12 小部件不会显示为选项(如屏幕截图 2 所示)。

当我尝试手动编码时(例如 app.pages.Reconciliation_Details.descendants.Label12.visible)它 returns 错误 "Cannot set property 'visible' of undefined".

为什么App Maker看不到Label12

屏幕截图 1 显示页面上的 Label12

屏幕截图 2 显示编码时缺少 Label12

App Maker 可以看到 Label12。关键是标签位于 table 小部件内,因此根据 documentation:

Because a table is a collection of other widgets, you can't use the Widget API to interact with a table. However, you can use scripts to manipulate the individual widgets that make up a table.

上面的语句是有道理的,因为 table 将显示的行数取决于数据源项目;即,在 ui 中加载小部件数据源时动态创建行。因此,为了访问标签,您需要首先访问 Table1Body 的子项,这是一个名为 PropertyMap.

的命名值集合

我相信您正在尝试 hide/show 基于某种逻辑的特定标签。正确的做法应该是这样的:

var rows = app.pages.Reconciliation_Details.descendants.Table1Body.children._values;
for(var i=0; i<rows.length; i++){
    var row = rows[i];
    var label = row.descendants.Label12;
    label.visible = true; // or false
}