Google App Maker总计字段

时间:2018-08-15 19:19:44

标签: google-app-maker

我有一个过滤列表,如下面的屏幕截图所示

screenshot of the filtered list

我想在一个单独的字段中计算总计“ Km”。

你能帮我吗?

以下是带有小部件结构的屏幕截图:

Structure Admin View

1 个答案:

答案 0 :(得分:1)

类似以下的方法将起作用:

TableListWidget.children._values
  .map(function(obj){ 
    return parseInt(obj.descendants.nameOfYourKMField.value);
  })
  .reduce(function(accumulator, currentValue){ 
    return accumulator + currentValue; 
  });

TableListWidget.children._vaues包含所有表行的数组,每行的descendants属性将包含具有KM值的小部件。我们将_values数组映射到KM字段值的数组,然后使用reduce函数将其添加。