function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Sorting html-autcomplete in Visualforce


I'm using the "list" attribute in apex:InputText tag in Visualforce to feed a list of String for autocomplete (html-autocomplete="on"). I've a requirement to display results in a sorted manner. Modifying/Sorting the underlying List<String> does not seem to have any impact. 

<apex:inputText id="InputBox" value="{!selectecValue}" list="{!autocomplete}" html-autocomplete="on"/>
--- Here autocomplete is of type: List<String>. Even after sorting the list in controller (as per business requirement) the display order in visualforce page remains the same.

Is there any way to do that? Any help will be appreciated..!!

Ayan - What the sample values in the list, in which order you are trying to display in the auto suggestion? It will be disaplyed ascending order by default, check the below screenshot. In the controller class, I stored the value in different order, but in the visualforce page, autosuggestion box disaplayed in the proper order

User-added image
Thanks for your reply. My requirement says: "Display user owned records on top of the list, followed by shared records". In case of a selectlist/dropdown, it can be done by concatenating the results of two Lists (UserOwned list and SharedRecord list). But in this case, I'm guessing it will always display the results in a alphabetical order.
Amit Chaudhary 8Amit Chaudhary 8
Hi Ayan,
Please check below blog. I hope that will help you:-

Please mark this as solution if this will help you.

Amit Chaudhary