In sap.m.Table/List, I defined a title
<Title
id="lineItemsHeader"
text="{tableView>/lineItemListTitle}"/>
Get count logic is in updateFinished
function,
onListUpdateFinished : function (oEvent) {
var sTitle,
iTotalItems = oEvent.getParameter("total"),
oViewModel = this.getModel("tableView");
// only update the counter if the length is final
if (this._oTable.getBinding("items").isLengthFinal()) {
if (iTotalItems) {
sTitle = this.getResourceBundle().getText("DETAIL_TABLE_HEADING_COUNT", [iTotalItems]);
} else {
//Display 'Line Items' instead of 'Line items (0)'
sTitle = this.getResourceBundle().getText("DETAIL_TABLE_HEADING");
}
oViewModel.setProperty("/lineItemListTitle", sTitle);
}
}
But if I set growing="true"
, when data is more than 20 items(default growing threshold), this._oTable.getBinding("items").isLengthFinal()
will return false
.
So I came up an idea, use $count
directly to get count data.
this._oModel.read("/ControlSet/$count", {
success: this._updateListItemCount.bind(this),
error: this.errorCallback.bind(this)
});
But the question came up when I try to get count of filter result, I know the call is /ControlSet/$count?$filter=(substringof('a',name) or substringof('a',description))
, and I've already maintain a filter state:
this._oListFilterState = {
aSearch : [new Filter...]
};
Did not find any clue in https://sapui5.hana.ondemand.com/#/api/sap.ui.model.Filter
Any suggestion? Try do fix this in an elegant/ui5 way, better not use $.get
Fixed by :
this._oListFilterState = {
aSearch : undefined
};
onUpdateFinished : function () {
this.byId("pullToRefresh").hide();
if(this._oListFilterState.aSearch) {
this._oModel.read("/ControlSet/$count", {
filters: [this._oListFilterState.aSearch],
success: this._updateListItemCount.bind(this),
error: this.errorCallback.bind(this)
});
}else {
this._oModel.read("/ControlSet/$count", {
success: this._updateListItemCount.bind(this),
error: this.errorCallback.bind(this)
});
}
},