簡體   English   中英

過濾值 sapui5 后,忙碌指示器不會停止

[英]Busy Indicator doesn't stop after filtering values sapui5

我有一個主從頁面。 在母版頁中,有一個帶有搜索欄的列表。 當我搜索列表中的項目時,搜索工作正常,但當我搜索不在列表中的項目時,會自動顯示忙碌指示符並且不會停止。 以下是我的搜索代碼:

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

    }

母版頁.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 返回成功 - 那么您對“data.d.QueryLoginToQueryList”的訪問可能無法解析並導致函數結束

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM