且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Appmaker-本地数据源与外部数据源/目录之间的关系

更新时间:2022-05-01 22:56:29

无法在目录模型和其他模型类型之间创建关系.您至少可以通过三种方法来解决此短缺问题:

There is no way to create relations between Directory Model and other model types. You have at least three ways to workaround this shortage:

一个

动态查询目录记录-可以很好地处理单记录页面,但是对于列表来说太慢了.

Query directory records on the fly - this will okish work for single-record pages, but it will be tooo slow for lists.

两个

您可以在表中复制所需的目录字段.

You can duplicate Directory fields you need in your tables.

优点:

  • 它不会降低您的应用速度
  • 它将使您能够使用混合模型数据(目录+驱动器表或Cloud SQL)实现查询

缺点:

  • 您将在两个不同的位置存储相同的数据
  • 最终,您的目录数据版本会过时

您可以在中找到第二种方法的不错的示例 人际交往应用.

You can find nice sample of the second approach in People Skills app.

三个

按需查询目录数据.假设您有数据绑定列表,并且绑定到列表的记录具有UserEmail字段.在这种情况下,您可以:

Query Directory data on demand. Let's say you have databound list, and records bound to the list have UserEmail field. In this case you can:

  1. 在列表行中添加一些按钮
  2. 在按钮onClick事件处理程序中添加类似于以下代码:

app.datasources.Directory.query.filters.PrimaryEmail._equals = widget.datasource.item.UserEmail;
app.datasources.Directory.load();
app.showPage(app.pages.UserDetails); // or app.showDialog(app.pages.UserDetails);