Is it possible to add values to table widget programmatically in Google Appmakers

♀尐吖头ヾ 提交于 2019-12-23 04:53:08

问题


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...

Thank you in advance :)


回答1:


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.

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.



来源:https://stackoverflow.com/questions/54532079/is-it-possible-to-add-values-to-table-widget-programmatically-in-google-appmaker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!