我已经在xml视图中创建了一个表,我想将该表绑定到控制器中
因此可以根据谁在加载应用程序来对其进行动态修改。
XML视图
<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控制器
var pHistory = this.byId("pTable");
var phURL = "/PMRPerformanceSet/?$filter=IvGuid eq '5438A43913276540E1008000A7E414BA'"
pHistory.setModel(oModel);
pHistory.bindRows(phURL);
似乎控制器应该看起来像这样,但是,这不起作用
有什么建议么?
最佳答案
我猜您正在使用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>
然后在控制器中设置模型。
在开发人员工具的“网络”标签中检查您的odata服务响应,然后根据该内容绑定项目
在XML视图中。