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.
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.
The binding portion
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'
}
});
The template:
<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?
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.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…