将 SmartTable 与实体集(实体的)绑定 [英] Bind SmartTable with entityset (of an entity)

查看:26
本文介绍了将 SmartTable 与实体集(实体的)绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于 sap.ui.comp.smarttable.SmartTable 绑定的问题.

I've got a question regarding the binding of a sap.ui.comp.smarttable.SmartTable.

我有两个实体,因此也有两个实体集,A 和 B.

I have two Entities and thereby also two Entitysets, A and B.

A 与 B 有 1 对 n 的关系,因此 A 的一个实例可以有(例如)5 个 B 的关联实例.

A has 1-to-n relationship to B, ergo one instance of A can have (for example) 5 instances of B associated.

我可以毫无问题地将我的 SmartTable 绑定到其中任何一个,但我想将它绑定到例如A('7')/B,仅获取与 A 的实例 7 关联的项目.如果我在浏览器中调用该路由,则可以正常工作(因此 oData 服务可以正常工作).

I can bind my SmartTable to either one of those without problem, but I want to bind it to e.g. A('7')/B, to only get items associated with the instance 7 of A. If I call that route in the browser, this works fine (so oData service works correctly).

但是,我无法弄清楚如何相应地绑定 SmartTable.我用不同的字符串在各种尝试中尝试了 tableBindingPath 和 entitySet,但没有成功.

However, I could not figure out how to bind the SmartTable accordingly. I tried tableBindingPath and entitySet in various attempts with different strings, but no luck.

你们中有人知道要实现这一目标吗?我们使用的是 XML 视图,但 JS 也可以.

Does anybody of you know to achieve this? We're using XML views but JS would also be fine.

推荐答案

由于没有代码,我会尽力回答这个问题.你需要绑定A('7')/B .
为此,智能表的 EntitySet=B(基于此智能表将为您构建列).
TableBindingPath 应该是从 A 到 B 的导航属性的名称.
但是对于这项工作,您应该在具有智能表的视图上设置模型.否则表上将没有数据.

Since there is no code i will try my best to answer this . You need to bind A('7')/B .
For this the smart table's EntitySet=B(based on this the Smart Table will build the columns for you).
TableBindingPath should be name of the navigation property from A to B.
But for this work you should have set the model on the View which has Smart Table. Otherwise there will no data on the table.

现在智能表中还有 1 个属性.
1. enableAutoBinding - 如果设置为true,那么智能表将自动将数据绑定到表.
2.如果设置为false,则需要显式调用Smart Table上的rebindTable方法

Now there are 1 more property in smart table .
1. enableAutoBinding - If this is set to true then the smart table will automatically bind the data to the table.
2. If it is set to false you will need to call explicitly the method rebindTable on the Smart Table

示例代码片段如下所示
智能桌id="智能表"entitySet = "POItems"tableType="响应表"enableAutoBinding="true"可编辑=真"tableBindingPath="项目"

A sample code snippet is shown below
SmartTable id="SmartTable" entitySet = "POItems" tableType="ResponsiveTable" enableAutoBinding="true" editable = "true" tableBindingPath="Items"

这里的 POItems 是服务中的实体的名称.Items 是从 POHeaders(示例中的 ===> A)到 POItems(示例中的 ===> B)的关联名称

Here POItems is the name of the entity in service. Items is the name of the association from POHeaders (===> A from your example) to POItems(=====> B from your example)

希望这会有所帮助.

干杯,维拉

这篇关于将 SmartTable 与实体集(实体的)绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆