是否可以在Google Appmakers中以编程方式向表窗口小部件添加值 [英] Is it possible to add values to table widget programmatically in Google Appmakers

查看:44
本文介绍了是否可以在Google Appmakers中以编程方式向表窗口小部件添加值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够在google app maker表格小部件中显示数据源数据,但是我不知道如何以编程方式向表格小部件显示静态值(对象数组). 我是应用程序制造商的新手,我不知道是否可以通过编程方式将值添加到表小部件. 如果有人知道,请帮助我...

I am able to show the data source data in google app maker table widget, but I don not know how to show static values (array of object) to table widgets programmatically. I am new to app maker,I don not know is it possible to add values to table widget programmatically or not. If any one knows please help me...

预先感谢您:)

推荐答案

要调用自己的create children方法,您需要设置一个与提供的图片类似的面板,并为该面板设置一个数据源,您想要为其提供项目出现在该面板中.

To call your own create children method you would want to set up a panel similar to the picture provided and set a datasource for that panel for which items you want to appear in that panel.

然后转到该面板的事件,并在onDataLoad事件中输入以下代码,因为它们与您自己的数据有关.在我的示例中,我使用了一个名为employee的数据源,并为该数据源中的每个项目创建了一个带有雇员姓名的标签.

Then go to events for that panel and in the onDataLoad event enter the following code as it pertains to your own data. In my example I used a datasource called employees, and I created a label with the employee name for each item in the datasource.

widget.datasource.items.forEach(function(item) {
  var node = document.createElement('div');
  node.className = 'app-Label';
  node.style.margin = '8px';
  node.textContent = item.EmployeeName;
  widget.getElement().appendChild(node);
});

那是我所拥有的最简单的例子.对于表,您需要创建自己的基本容器,标头,然后创建一个容纳所有表行的容器.然后,在表主体中,将设置一个类似的脚本来附加行面板,并在行面板中创建标签.也可以声明自己的对象数组,并以此方式遍历每个对象.

That is about the simplest example I have. In the case of a table you would want to create your own base container, a header, and then a container that holds all your table rows. Then in your table body you would set up a similar script that attaches row panels and in the row panels you would create your labels. This would also be possible to declare your own array of objects and loop over each object this way.

这篇关于是否可以在Google Appmakers中以编程方式向表窗口小部件添加值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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