Skip to Content
Mar 03, 2021 at 08:45 PM

How to properly call SearchField's 'suggest' method (instead of) using 'dataReceived' event?

43 Views Last edit Mar 03, 2021 at 08:46 PM 2 rev

UI5 1.84.8

OData model V4

This is my workaround implementation. I don't want to use this ugly timer workaround. Do you know how to call this correctly?

        onSuggest: function(oEvent){
            var oSource = oEvent.getSource();
            var sTerm = oEvent.getParameter("suggestValue");
            if(sTerm.length === 0) {
            var aFilters = [];
            if (sTerm) {
                aFilters.push(new Filter("title", FilterOperator.StartsWith, sTerm));
            var oBinding = oSource.getBinding("suggestionItems")
            oBinding.attachEventOnce('dataReceived', function() {
                setTimeout(() => {
                }, 100)

Without this timeout, the list will show up blank 50% of the time. The number of items in the list corresponds to the number items in the entity set, but none of the labels are visible. The other 50% of the time it shows up fine. Why am I (seemingly) the only person on the internet with this issue?

Instead of using 'attachEventOnce' on the binding, I think it could possibly be solved by calling 'attachEventOnce' for the event 'updateFinished' on the list of the suggestions. I don't know how to get a hold of that list element though.