在sap fiori应用程序中,搜索栏正在处理模拟数据,而不是后端数据(sap ABAP(odata))
文件名:Master.Controller.js
onSearch : function() {
this.oInitialLoadFinishedDeferred = jQuery.Deferred();
// Add search filter
var filters = [];
var searchString = this.getView().byId("searchField").getValue();
if (searchString && searchString.length > 0) {
filters = [ new sap.ui.model.Filter("QUARTER_ID", sap.ui.model.FilterOperator.Contains, searchString) ];
}
// Update list binding
this.getView().byId("list").getBinding("items").filter(filters);
//On phone devices, there is nothing to select from the list
if (sap.ui.Device.system.phone) {
return;
}
//Wait for the list to be reloaded
this.waitForInitialListLoading(function () {
//On the empty hash select the first item
this.selectFirstItem();
});
},
filename:Master.view.xml
<subHeader id="masterSubHeader">
<Bar id="searchBar">
<contentMiddle>
<SearchField
id="searchField"
livechange= "onSearch"
width="100%">
</SearchField>
</contentMiddle>
</Bar>
</subHeader>
<content>
<List
id="list"
select="onSelect"
mode="{device>/listMode}"
noDataText="{i18n>masterListNoDataText}"
growing="true"
growingScrollToLoad="true"
items="{/quarterviewSet}">
<items
id="masterList">
<ObjectListItem
id="mainListItem"
press="onSelect"
type="{device>/listItemType}"
counter="0"
title="{QUARTER_ID}"
number="{QTRTYPE_NAME}"
numberUnit="{QUARTER_CATEGORY}"
markFavorite="false"
markFlagged="false"
showMarkers="false">
<attributes>
<ObjectAttribute id="ATTR1" text="{LOCATION}" />
<ObjectAttribute id="ATTR2" text="{CITY}" />
</attributes>
<core:ExtensionPoint
name="extListItemInfo"/>
</ObjectListItem>
</items>
</List>
</content>
答案 0 :(得分:0)
您必须弄清楚后端的数据是否与模拟数据相同。如果没有,绑定可能会出错。请检查数据是否最初加载到列表中,包含所有后端数据。之后,尝试进行搜索。
在onSearch
函数中放置一个断点,看看数据是否仍然存在,以及如何创建过滤器。