How to detect number of suggestions shown in suggestion view

Anurag

Fo my nativescript angular app I wanted to detect the number of matching suggestions that are shown in the suggestion view so that I can trigger a specific action when no matching suggestions are found. I tried the following code which seems to work in IOS but not in android. Please advise on how I can get the number of matching suggestions on both IOS and android.

Nikolay Iliev

The filteredItems property behind RadAutoCompleteTextView is private at this point (accessible only when no explicit casting to RadAutocCompleteTextView)
This means that we are not officially released the property as functionality and the future implementation may change.
All above considered the filteredItems property is an experimental feature not officially released but our development team is working on it.
Currently, there is no viable option to access the length of the filtered item on Android.

For your convenience, I have logged your issue as a feature request here, and you can track its development and possible workarounds in the linked issue.

Nikolay Iliev

One way to workaround this issue (getting the list of visible suggestions and/or detecting when there are not visible suggestions) is to directly handle the native
EditText control used in RadAutoCompleteTextView on Android. After accessing the native control, you can overwrite the native event listener using NativeScript marshaling (data conversion from Java to JavaScript) and implement your own logic to detect if the user input is part of some of the suggestions (startstWith or contains depending on the used suggestion mode).

With the solution above, we are directly overwriting the native event handler for Android. When the user inputs any characters, the afterTextChanged event will be triggered, and
in this event, we will check our suggestions for matching queries (depending on the logic you can use startsWith, contains or other JavaScript methods)

Keep in mind, that the above solution will work for Android (for iOS you can still use filteredItems) and our development team is considering providing this as out-of-the-box functionality. The feature request is logged here and I have upvoted the feature request via your ticket.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.