聚合绑定只显示最后一项 [英] Aggregation binding only shows last item

查看:20
本文介绍了聚合绑定只显示最后一项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试将聚合绑定到 Table 控件,但结果行与数据集中的最后一个结果重复.详细地说,该表包含正确数量的行和列,但每行重复相同的数据.

Hello I am trying to bind an aggregation onto a Table control but the resulting rows are repeated with the last result in the data set. To elaborate, the table contains the correct amount of rows and columns, but each row repeats the same data.

执行 OData 读取调用并将结果放入 JSON 模型并将该模型绑定到表上是可行的,但这似乎不必要地昂贵.

Doing a OData read call and putting the results into a JSON model and binding that model onto the table works, but that seems unnecessarily expensive.

绑定部分

var filter = new Filter("itemID", sap.ui.model.FilterOperator.EQ, this.item.itemID);  
this._template = this._template ? this._template : sap.ui.xmlfragment("InventoryListItem", this.getView().getController());
this.inventoryList.bindAggregation("items", {
    path: "oDataModel>/InventoryUsages",
    filters: [filter],
    template: this._template,
    parameters: {
      select: 'inventoryID,memberID,fName,lName,condition,purchasedAt,price'
   }
});

模板:

<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:l="sap.ui.layout">
<ColumnListItem>
    <cells>
        <Text text="{path: 'oDataModel>inventoryID'}" />
        <Text text="{parts:[{path:'oDataModel>fName'}, {path:'oDataModel>lName'}], formatter:'.nameFormater'} " />
        <Text text="{oDataModel>purchasedAt}" />
        <RatingIndicator maxValue="5" class="sapUiSmallMarginBottom" value="{
            path: 'oDataModel>condition', formatter: '.conditionFormat'}"
            change="onRatingPress"/>
        <Text text="{path:'oDataModel>price', formatter: '.priceFormatter'}" />
        <Button text="Remove"
            icon="sap-icon://delete"
            press="onRowDelete"
            class="appBtn"/>
    </cells>
</ColumnListItem>

表格显示正确的行数和列数,但数据错误.它将显示每行集合中的最后一个结果.当表格增长时,表格将显示集合中的下一个最后结果.有谁知道我该如何解决这个问题?

The table displays the correct number of rows, and columns but the data is wrong. It will display the last result in the set for each row. When the table grows the table will show the next last result in the set. Does anyone know how i can fix this?

答案:原来我是在一个没有主键的视图上进行 OData 调用.渲染出现故障,结果由于某种原因只显示最后一个结果.

Answer: Turns out i was doing an OData call on a view that didn't have a primary key. The render glitches out and only displays the last result for some reason as a result.

推荐答案

好吧,我找到了我自己问题的答案,原来是因为我正在对没有主键的视图进行 OData 调用.如果它没有主键,它将出现故障并显示数据集的最后一个结果.(如果你使用的是 ASP.net web api,你可以在模型中添加 [key] 注释来解决这个问题).

Well I figured out the answer to my own question it turns out because I am doing an OData call to a view that does not have a primary key. If it doesn't have a primary key it will glitch out and display the last result of the data set. (If you are using a ASP.net web api you can just put the [key] annotation in the model to solve this problem).

这篇关于聚合绑定只显示最后一项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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