How to include a relation of a relation in an AppM

2019-03-04 00:07发布

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条回答
【Aperson】
2楼-- · 2019-03-04 00:39

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

查看更多
登录 后发表回答