Saya memiliki halaman Master-Detail. Di halaman master, ada daftar yang memiliki bilah pencarian. Ketika saya mencari item yang ada dalam daftar, pencarian berfungsi dengan baik tetapi ketika saya mencari item yang tidak ada dalam daftar, indikator sibuk ditampilkan secara otomatis dan tidak berhenti. Di bawah ini adalah kode saya untuk pencarian:
onInit: function () {
this.router = sap.ui.core.UIComponent.getRouterFor(this);
this._custTemp = this.getView().byId("listItemTemp").clone();
this.refreshFlag = true; // Flag to get new data or not for customers
this.totalModel = sap.ui.getCore().getModel("totalModel");
this.getView().setModel(this.totalModel, "totalModel");
this.oInitialLoadFinishedDeferred = jQuery.Deferred();
var oEventBus = sap.ui.getCore().getEventBus();
this.getView().byId("listId").attachEvent("updateFinished", function () {
this.oInitialLoadFinishedDeferred.resolve();
oEventBus.publish("MasterPage", "InitialLoadFinished", {
oListItem: this.getView().byId("listId").getItems()[0]
});
if (!sap.ui.Device.system.phone) {
this._getFirstItem();
}
}, this);
},
waitForInitialListLoading: function (fnToExecute) {
jQuery.when(this.oInitialLoadFinishedDeferred).then(jQuery.proxy(fnToExecute, this));
},
_getFirstItem: function () {
sap.ui.core.BusyIndicator.show();
this.waitForInitialListLoading(function () {
// On the empty hash select the first item
var list = this.getView().byId("listId");
var selectedItem = list.getItems()[0];
if (selectedItem) {
list.setSelectedItem(selectedItem, true);
var data = list.getBinding("items").getContexts()[0];
sap.ui.getCore().getModel("detailModel").setData(data.getObject());
sap.ui.getCore().getModel("detailModel").refresh(true);
this.router.navTo('DetailPage', {
QueryNo: data.EICNO
});
sap.ui.core.BusyIndicator.hide();
}
}, this);
},
onBeforeRendering: function () {
this._fnGetData();
},
_fnGetData: function (oEvent) {
var that = this;
this.getView().setModel(this.totalModel, "totalModel");
if (this.refreshFlag === true) {
sap.ui.core.BusyIndicator.show(0);
$.ajax({
url: "/sap/opu/odata/sap/ZHR_V_CARE_SRV/EmpQueryInitSet('10002001')?$expand=QueryLoginToQueryList/QueryToLog",
method: "GET",
dataType: "json",
success: function (data) {
that.getView().getModel("totalModel").setData(data.d.QueryLoginToQueryList);
that.refreshFlag = false;
sap.ui.core.BusyIndicator.hide();
that._getFirstItem();
}
});
},
onSearch: function (oEvent) {
var that = this;
var sValue = oEvent.getSource().getValue();
if (sValue !== "") {
var oFilter1 = new Filter("FunctionDes", sap.ui.model.FilterOperator.Contains, sValue);
var oFilter2 = new Filter("EICNO", sap.ui.model.FilterOperator.Contains, sValue);
var oFilter3 = new Filter("REQSTATUS", sap.ui.model.FilterOperator.Contains, sValue);
var oFilter = new Filter({
filters: [oFilter1, oFilter2, oFilter3],
and: false
});
var oBinding = this.getView().byId("listId").getBinding("items");
oBinding.filter([oFilter]);
} else {
oBinding = this.getView().byId("listId").getBinding("items");
oBinding.filter();
}
},
}
Halaman Master.xml
<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:html="http://www.w3.org/1999/xhtml"
controllerName="hmel.WeCareEmp.controller.MasterPage">
<Page title="Queries" backgroundDesign="Solid">
<subHeader>
<Bar>
<contentLeft>
<SearchField id="searchField" placeholder="Search by Function. Eg: Salary" liveChange="onSearch" showRefreshButton="{device>/isNoTouch}"
enableSuggestions="true"/>
</contentLeft>
</Bar>
</subHeader>
<content>
<List id="listId" items="{ path : 'totalModel>/results' }" noDataText="No Data" mode="SingleSelectMaster" growing="true" growingThreshold="100" growingScrollToLoad="true" selectionChange="onListSelect">
<items>
<ObjectListItem id="listItemTemp" type="Active" title="Date : {totalModel>SENT_ON}">
<attributes>
<ObjectAttribute title="Query No" text="{totalModel>EICNO}"/>
<ObjectAttribute title="Function" text="{totalModel>FunctionDes}"/>
<ObjectAttribute title="Query open with" text="{path: 'totalModel>OPENWITH', formatter:'hmel.WeCareEmp.controller.formatter.queryOpenWith'}"/>
</attributes>
<firstStatus>
<ObjectStatus text="{path:'totalModel>REQSTATUS', formatter:'hmel.WeCareEmp.controller.formatter.status'}"/>
</firstStatus>
</ObjectListItem>
</items>
</List>
</content>
</Page>