如何在 google 应用程序制造商中使用表格添加/编辑/删除多对多关系?
How add / edit / remove many to many relationships in google app maker using tables?
我有以下场景围绕两个模型之间的关系:资产和活动。
许多资产可以同时作为许多活动的输入。
考虑到这一点 - 我想创建 UI,它允许我:
从Activity的角度来看:
将与 Activity 相关的资产添加到 table,方法是从显示所有已创建资产的现有 table 资产中选择它们。
可以通过单击按钮删除关系(这不会删除 table 中的整个记录)。
请帮忙。提前致谢!
我尝试将自定义代码绑定到按钮的 onClick 事件,该按钮与资产记录位于同一行,我想取消与关联 activity 的关联:
var index = widget.root.datasource.item.Assets.indexOf(widget.datasource.item);
widget.root.datasource.item.Assets.splice(index, 1);
这个returns:
无法读取未定义的 属性 'indexOf'
在 Strategy_TableView.Panel1.Table2.Table2Body.Table2Row.Button5.onClick:1:51
我还没有尝试找到一种方法来将现有资产添加到与活动相关的资产中 table。
为使其正常工作而建议的代码编辑为:
var datasourcerelation = widget.root.datasource.relations.Services;
var index = datasourcerelation.items.indexOf(widget.datasource.item);
datasourcerelation.items.splice(index, 1);
无论出于何种原因,引用与 JS 数组函数相关的 datasource.item.Services
都不会为您提供所需的结果。我不确定这是为什么,但您必须改用 datasource.relations.Services
。
关于添加关系使用:
var datasourcerelation = widget.root.datasource.item.Services;
datasourcerelation.push(widget.datasource.item);
请注意,在添加关系的情况下,datasource.item.Services
工作正常。我不确定为什么会有所不同。
我有以下场景围绕两个模型之间的关系:资产和活动。
许多资产可以同时作为许多活动的输入。
考虑到这一点 - 我想创建 UI,它允许我:
从Activity的角度来看:
将与 Activity 相关的资产添加到 table,方法是从显示所有已创建资产的现有 table 资产中选择它们。
可以通过单击按钮删除关系(这不会删除 table 中的整个记录)。
请帮忙。提前致谢!
我尝试将自定义代码绑定到按钮的 onClick 事件,该按钮与资产记录位于同一行,我想取消与关联 activity 的关联:
var index = widget.root.datasource.item.Assets.indexOf(widget.datasource.item);
widget.root.datasource.item.Assets.splice(index, 1);
这个returns:
无法读取未定义的 属性 'indexOf' 在 Strategy_TableView.Panel1.Table2.Table2Body.Table2Row.Button5.onClick:1:51
我还没有尝试找到一种方法来将现有资产添加到与活动相关的资产中 table。
为使其正常工作而建议的代码编辑为:
var datasourcerelation = widget.root.datasource.relations.Services;
var index = datasourcerelation.items.indexOf(widget.datasource.item);
datasourcerelation.items.splice(index, 1);
无论出于何种原因,引用与 JS 数组函数相关的 datasource.item.Services
都不会为您提供所需的结果。我不确定这是为什么,但您必须改用 datasource.relations.Services
。
关于添加关系使用:
var datasourcerelation = widget.root.datasource.item.Services;
datasourcerelation.push(widget.datasource.item);
请注意,在添加关系的情况下,datasource.item.Services
工作正常。我不确定为什么会有所不同。