List all records

I have a requirement that when I click in the box, all available values should be displayed. When the user types, the available values should be limited accordingly.

I have seen that I can display all values via showPopup.

However, when the user deletes his input, I have the problem that no more values are displayed to me. I would then like to display the list with all entries again.

Is there a solution for this?


1 Reply

UD UdhayaKumar Duraisamy Syncfusion Team June 20, 2023 06:25 PM UTC

You can use the showPopup method to display the popup while focusing on the AutoComplete component using Focus event. Additionally, in the Filtering event, you can check the length of the input text. If it is 0, you can call the showPopup method, which will display all the data items in the popup. For further information, please refer to the code snippet below.


<div style="margin:130px auto;width:300px">

    @Html.EJS().AutoComplete("games").Placeholder("Select a Game").Focus("onFocus").Filtering("onFiltring").DataSource((IEnumerable<object>)ViewBag.data).Fields(new Syncfusion.EJ2.DropDowns.AutoCompleteFieldSettings { Value = "Game" }).Render()

</div>

 

<script>

    function onFocus(args) {

        document.getElementById('games').ej2_instances[0].showPopup();

    }

    function onFiltring(args) {

        if (args.text.length == 0) {

            setTimeout(function () {

                document.getElementById('games').ej2_instances[0].showPopup();

            },100);

        }

    }

</script>




Documentation:


Loader.
Up arrow icon