在 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();
});
},
文件名: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>