Javascript 忙指示灯不工作';t在筛选值sapui5后停止

Javascript 忙指示灯不工作';t在筛选值sapui5后停止,javascript,filter,sapui5,sap-fiori,Javascript,Filter,Sapui5,Sap Fiori,我有一个母版详细页。在母版页中,有一个带有搜索栏的列表。当我搜索列表中的项目时,搜索工作正常,但当我搜索列表中不存在的项目时,会自动显示一个忙碌指示器,并且不会停止。以下是我的搜索代码: onInit: function () { this.router = sap.ui.core.UIComponent.getRouterFor(this); this._custTemp = this.getView().byId("listItemTemp").cl

我有一个母版详细页。在母版页中,有一个带有搜索栏的列表。当我搜索列表中的项目时,搜索工作正常,但当我搜索列表中不存在的项目时,会自动显示一个忙碌指示器,并且不会停止。以下是我的搜索代码:

    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();
        }
    },

    }
MasterPage.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>


查看您的代码,我怀疑问题与AJAX调用有关,可能是:

  • 如果找不到筛选器项,GET将返回一个错误-那么您应该添加一个隐藏忙碌控件的“错误”处理程序
  • 如果找不到筛选器项,GET将返回success-那么可能无法解析对“data.d.QueryLoginToQueryList”的访问,并导致函数结束

  • 查看您的代码,我怀疑问题与AJAX调用有关,可能是:

    • 如果找不到筛选器项,GET将返回一个错误-那么您应该添加一个隐藏忙碌控件的“错误”处理程序
    • 如果找不到筛选器项,GET将返回success-那么可能无法解析对“data.d.QueryLoginToQueryList”的访问,并导致函数结束

    你试过把它放在导航台之前吗?@Jungkook是的,但没用。我还没有写任何显示忙碌指示器的代码。它通过一些标准的UI5方法显示。哪个控件正忙?您使用odata模型绑定还是本地模型?@Voyager I使用本地模型。因此,绑定项目后,忙碌指示灯将出现。@Swappy请加强问题并提供一个示例。根据目前的信息,很难确定问题所在。请同时添加分发版本。按[Ctrl]+[Left Alt]+[Shift]+[P]可以在“技术信息”对话框中找到它。您是否尝试将它放在导航按钮之前?@Jungkook是的,但它不起作用。我还没有写任何显示忙碌指示器的代码。它通过一些标准的UI5方法显示。哪个控件正忙?您使用odata模型绑定还是本地模型?@Voyager I使用本地模型。因此,绑定项目后,忙碌指示灯将出现。@Swappy请加强问题并提供一个示例。根据目前的信息,很难确定问题所在。请同时添加分发版本。您可以通过按[Ctrl]+[Left Alt]+[Shift]+[P]在“技术信息”对话框中找到它。我已经添加了错误处理程序。我在StackOverflow上删除了它们以缩短代码。我已经添加了错误处理程序。我在StackOverflow上删除了它们以缩短代码。