Search code examples
liferayliferay-6liferay-aui

How to display limited entity in AUI: Autocomplete search suggetion


To search user by userId i am using aui: autocomplete, Is there any attribute available to display a limit number of entities in search result as i have a large number of users and while searching it is taking too much of time to load it.

 new A.AutoCompleteList(
            {
                allowBrowserAutocomplete: 'true',
                inputNode: '#search_id',
                resultTextLocator: 'userId',
                render: 'true',
                resultHighlighter: 'phraseMatch',
                resultFilters:['phraseMatch'],
                source:userAgList,
            })

Solution

  • Looking at the AutoCompleteList documentation: https://alloyui.com/api/classes/AutoCompleteList.html it seems that there is an attribute for this: maxResults.

    Probably using it at the end of your code is enough:

     new A.AutoCompleteList(
            {
                allowBrowserAutocomplete: 'true',
                inputNode: '#search_id',
                resultTextLocator: 'userId',
                render: 'true',
                resultHighlighter: 'phraseMatch',
                resultFilters:['phraseMatch'],
                source:userAgList,
                maxResults: 20
            })
    

    Anyway this solution may change depending on the version of AlloyUI.