我在xml View 中创建了一个表,我想在 Controller 中绑定(bind)该表 因此它可以根据谁加载应用程序进行动态修改。
XML View
<Table inset="false"
id="pTable">
<columns>
<Column id="year" width="auto">
<Text text="Year" />
</Column>
<Column id="rating" width="auto">
<Text text="Performance Rating"/>
</Column>
<Column id="respect" width="auto">
<Text text="Managing with Respect" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text id="tYear" text="{Begda}" />
<Text id="tRating" text="{Rating}" />
<Text id="tRespect" text="{MwrRating}" />
</cells>
</ColumnListItem>
</items>
</Table>
JS Controller
var pHistory = this.byId("pTable");
var phURL = "/PMRPerformanceSet/?$filter=IvGuid eq '5438A43913276540E1008000A7E414BA'"
pHistory.setModel(oModel);
pHistory.bindRows(phURL);
看起来 Controller 应该看起来像这样,但是,这不起作用
有什么建议吗?
最佳答案
我猜你正在使用 sap.m.Table:
<Table id="pTable"
inset="false"
items="{/PMRPerformanceSet}"> // add items Here for your oData collection
<columns>
<Column id="year" width="auto">
<Text text="Year" />
</Column>
<Column id="rating" width="auto">
<Text text="Performance Rating"/>
</Column>
<Column id="respect" width="auto">
<Text text="Managing with Respect" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text id="tYear" text="{Begda}" />
<Text id="tRating" text="{Rating}" />
<Text id="tRespect" text="{MwrRating}" />
</cells>
</ColumnListItem>
</items>
</Table>
然后在 Controller 中设置模型。 在开发人员工具的“网络”选项卡中检查您的 odata 服务响应,然后根据该响应绑定(bind)项目 在 XML View 中。
关于javascript - 从 SAPUI5 中的 Controller 动态绑定(bind)表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27135788/