How to include a relation of a relation in an AppMaker table field?

。_饼干妹妹 提交于 2019-12-31 05:30:11

问题


I have three data models, Partner, Client and SOW, where Client is a one-to-many relation to SOW, and Partner is a one-to-many relation to Client. I would like to include Partner Name as a column in a table displaying SOWs. Is there a way to do this with a datasource query script? Or a different approach altogether? I was able to add a label to the SOW table row that is data bound to the Partner name via relation, but I have yet to tackle sorting and filtering by Partner, and this method appears to fetch Partner real-time after the table loads. I am currently using Drive Tables as my datasource, but am open to switching to Cloud SQL.


回答1:


You can manually add header and 'cell'(one more label in list row).

Binding for the label in the header:

@models.Partner.fields.Name.displayName

Binding for the label in the list row:

@datasource.item.Client.Partner.Name

And don't forget to add both Client and Client.Partner relations to Prefetch, it should make your page load/render faster.

Useful tip:

You can copy/paste existing table labels to duplicate all original margins/paddings/styles and make them look/behave in the same way as all other labels within the table. In this case you'll need just to adjust your bindings and maybe rename some things.

Note:

Most likely you'll not be able to sort your table by relation of relation, but feel free to try(checkout onClick event handlers of labels in the table header).



来源:https://stackoverflow.com/questions/47820165/how-to-include-a-relation-of-a-relation-in-an-appmaker-table-field

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