ตัวบ่งชี้ไม่ว่างไม่หยุดหลังจากการกรองค่า 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();
        }
    },

    }

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>


person Swappy    schedule 25.02.2020    source แหล่งที่มา
comment
คุณได้ลองวางไว้หน้า navTo แล้วหรือยัง?   -  person Jungkook    schedule 25.02.2020
comment
@Jungkook ใช่ แต่มันใช้งานไม่ได้ ฉันยังไม่ได้เขียนโค้ดใด ๆ เพื่อแสดงตัวบ่งชี้ที่ไม่ว่าง มันถูกแสดงโดยวิธี UI5 มาตรฐานบางอย่าง   -  person Swappy    schedule 25.02.2020
comment
การควบคุมใดที่ไม่ว่างกันแน่? คุณใช้การเชื่อมโยงโมเดล odata หรือโมเดลท้องถิ่นหรือไม่?   -  person Voyager    schedule 25.02.2020
comment
@Voyager ฉันใช้โมเดลท้องถิ่น ดังนั้นหลังจากผูกไอเท็มแล้ว ตัวบ่งชี้ไม่ว่างกำลังมา   -  person Swappy    schedule 25.02.2020
comment
@Swappy โปรดปรับปรุงคำถามและระบุ mvce ด้วยข้อมูลปัจจุบัน การระบุปัญหาจึงเป็นเรื่องยาก โปรดเพิ่มเวอร์ชันการจำหน่ายด้วย คุณสามารถดูได้ในกล่องโต้ตอบข้อมูลทางเทคนิคโดยกด [Ctrl]+[Alt ซ้าย]+[Shift]+[P]   -  person Boghyon Hoffmann    schedule 25.02.2020


คำตอบ (1)


เมื่อดูรหัสของคุณ ฉันสงสัยว่าปัญหาเกี่ยวข้องกับการโทร AJAX และอาจเป็น:

  • GET ส่งกลับข้อผิดพลาดหากไม่พบรายการตัวกรอง - จากนั้นคุณควรเพิ่มตัวจัดการ 'ข้อผิดพลาด' ที่ซ่อนการควบคุมที่ไม่ว่าง
  • GET ส่งคืนความสำเร็จหากไม่พบรายการตัวกรอง - ดังนั้นการเข้าถึง 'data.d.QueryLoginToQueryList' ของคุณอาจไม่ได้รับการแก้ไขและทำให้ฟังก์ชันสิ้นสุด
person Steven DS    schedule 28.02.2020
comment
ฉันได้เพิ่มตัวจัดการข้อผิดพลาดแล้ว ฉันลบมันออกจาก StackOverflow เพื่อทำให้โค้ดสั้นลง - person Swappy; 02.03.2020